TheWennerWoman
Active Member
- Joined
- Aug 1, 2019
- Messages
- 301
- Office Version
- 365
- Platform
- Windows
VBA Code:
Sub Email_Mapping()
Dim wsSheet1, wsSheet2, wsSheet3 As Worksheet
Dim LastRow As Long
Application.Calculation = xlCalculationAutomatic
Set wsSheet1 = Worksheets("statements list")
LastRow = wsSheet1.Columns(1).Find("*", LookIn:=xlValues, SearchDirection:=xlPrevious).Row
wsSheet1.Range("B2").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],'statements email mapping'!C[-1]:C,2,FALSE),""CHECK"")"
wsSheet1.Range("C2").Value = "Y"
wsSheet1.Range("B2").AutoFill Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault '<<< fails on this line
wsSheet1.Range("C2").AutoFill Destination:=Range("C2:C" & LastRow), Type:=xlFillDefault
wsSheet1.Columns("A:D").Select
wsSheet1.Columns("A:D").EntireColumn.AutoFit
End Sub
If I F8 this it runs perfectly, if I trying running the macro from a button it errors?
What have I missed?
Many thanks as always for your help.