Splitting a url via ? mark

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I use this to split a url, it works fine unless there is a question mark, I have been struggling to set it to split the url if there is a ? in it. can someone please advise

VBA Code:
   If InStr(x, "/about") = 0 Then
            z = Split(x, "/")
        For j = LBound(z) To UBound(z)
            If InStr(z(j), "Google.com") Then x = "https://www.Google.com/" & z(j + 1) & "/about": Exit For
        Next
    End If
    
       If InStr(x, "?") = 0 Then
            z = Split(x, "?")
        For j = LBound(z) To UBound(z)
            If InStr(z(j), "Google.com") Then x = "https://www.Google.com/" & z(j + 1) & "/about": Exit For
        Next
    End If
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
It ok I fixed it with a Text to column, before the above code runs

VBA Code:
 Set wb = ThisWorkbook
   With wb.Sheets("Data")
   
        .Columns("A:A").TextToColumns _
            Destination:=Range("A1"), _
            DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, _
            ConsecutiveDelimiter:=False, _
            Tab:=True, _
            Semicolon:=False, _
            Comma:=False, _
            Space:=False, _
            Other:=True, _
            OtherChar:="?", _
            FieldInfo:=Array(Array(1, 1), Array(2, 9))
     End With
 
Upvote 0
Solution

Forum statistics

Threads
1,215,482
Messages
6,125,061
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top