If I have some variables that changes a lot while running through the code, what is the proper way to "refresh" those variables.
For instance lets say I have a couple variable like below and I use the same code many times:
lsheetname = Sheets("Sheet1").Cells(lRow, lCol).Value
lheadline = Sheets("Sheet1").Cells(lRow + 1, lCol).Value
If lsheetname = "" Or lheadline = "" Then
lLastRow = 0
Else
lmatchcol = WorksheetFunction.Match(lheadline, Sheets(lsheetname).Range("1:1"), 0)
lLastRow = Sheets(lsheetname).Cells(Rows.Count, lmatchcol).End(xlUp).Row
End If
Should this code be put in a function or in another sub and what would that function/sub then look like, if I need to use the returned values in my primary sub?
Bookmarks