I had my constant string defined as the cell, like this:
Const LID_LIFTED As String = "A19"
Everything seemed to be fine, but as I convert batch stuff from PDF to Excel, the rows are shifted slightly therefore the value from A19 finally might fall at A18 or even A16. I came to the conclusion, that better could be to grip my constant value as the string occurrence and then think about the offsets or something.
I don't know how to assign part of the string to my Const value
I tried:
Const LID_LIFTED As String = Like *"Lifted*"
I also considered:
https://excelmacromastery.com/excel-vba-find/
Dim rng1 As Range
Set rng1 = Range("A1:A100").Find("*lifted*")
Const LID_LIFTED As String = rng1
I got an error:
"Constant expression required"
Another option below:
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
Dim String1 As String
String1 = ws.Range("A1:A100").Find(what:="lifted", lookat:=xlWhole)
threw error:
"Object variable or with variable not set"
and the third option:
Dim txt1 As Long
txt1 = Application.WorksheetFunction.Match("*lifted*", Range("A1:A100"), 0)
didn't work with the following error:
"Unable to get the Match property of the WorksheetFunction class"
How can I include part of the string in my Const value?