I have a worksheet with 4 columns, I've written a macro to put formula in columns A + B that are dependent on what is in column D, then copy and paste as values to enable filtering of those columns. My problem is that on a weekly basis column D becomes longer. I don't want to have to keep changing the values in my Macro for the range of A + B (A2:A69422) where 69422 is the last used cell in column D.
Worksheets("salesinfo").Range("B2").Formula = "= MID(D3,3,5)"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B69422")
Range("B2:B69422").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Value = Selection.Value
Range("A2").Formula = "= VLOOKUP(B2,[Data.xlsb]Stores!$A:$X,4,0)"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A69422")
Range("A2:A69422").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks("Data.xlsb").Close SaveChanges:=False
Application.CutCopyMode = False
Range("A2").Select