Translating excel formula to VBA format with match() and left()

dcass

New Member
Joined
Jun 7, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hello! I have this formula in Excel that finds the cell with the http based link. I have to use the left() language because the links in our spreadsheets are often greater than the 250 characters that match can handle. Here's the formula in Excel: =MATCH("htt*", LEFT(B1:B30, 200), 0), which is returning the correct value. I need to incorporate this into VBA and assign the value to a variable.

This was my attempt to write that line: Var4 = Application.Match("htt*", Left(Range("B1:B30").Value, 200), 0)
But I get an error mismatch dialog. Can someone point me to what i'm doing incorrectly here? Basically I don't know how to nest the Left() function into the match function that i'm using in VBA. Thank you!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try:
VBA Code:
Sub test()
    Dim var4 As Range
    Set var4 = Range("B1:B30").Find("htt", LookIn:=xlValues, lookat:=xlPart)
    MsgBox (var4 & " is found in cell " & var4.Address(0, 0))
End Sub
 
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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