Reputation: 3460
Input format = https://instagram.com/baby_blues_tattoos/
or = https://instagram.com/baby_blues_tattoos
Expected Final Value for variable usname
= followers/baby_blues_tattoos
Current Final Value for Variable usname
= followers/
I am not able to extract the username from the input using the code below Need help.
Option Explicit
Sub InstaUs()
Dim wk, ws, wc As Worksheet
Set wk = Sheets(3) 'Art
Set ws = Sheets(2) 'Shop
Set wc = Sheets(10) 'Output
Dim str, i, j, l, FinalRowArt, FinalRowShop, FinalRowOut, fol
Dim Cet, usname
fol = "followers/"
FinalRowArt = wk.Range("M900000").End(xlUp).Row
FinalRowShop = ws.Range("L900000").End(xlUp).Row
FinalRowOut = wc.Range("A900000").End(xlUp).Row
j = 2
For i = 2 To FinalRowArt
If wk.Range("M" & i) <> "" Then
str = wk.Range("M" & i).Value
Cet = Split(str, "/")
usname = Cet(UBound(Cet))
usname = fol & usname
wc.Range("A" & j) = usname
j = j + 1
Else: End If
Next i
For i = 2 To FinalRowShop
If ws.Range("L" & i) <> "" Then
str = ws.Range("L" & i).Value
Cet = Split(str, "/")
usname = Cet(UBound(Cet))
usname = fol & usname
wc.Range("A" & j) = usname
j = j + 1
Else: End If
Next i
End Sub
Upvotes: 2
Views: 384
Reputation: 27269
Add an If
statement once you establish str
If Right(str, 1) = "/" Then
Cet = Split(Mid(str, 1, Len(str) - 1), "/")
Else
Cet = Split(str, "/")
End If
Upvotes: 1