I'm trying to get this macro to run when the workbook is opened and keep running the whole time. I get no error, but the macro is not running in the background. Can anyone see why this is not working?
Sub Input_NA()
With ActiveWorkbook
.RunAutoMacros xlAutoActivate
End With
Dim cell As Object
Dim reportlocation As String
Dim sh As String
Dim strvar As String
Dim p As Integer
Dim m As String
strvar = "N/A"
sh = "1244 HT-DOC 12"
p = p + 1
m = p + 1
For Each cell In Range("L9:L42")
If cell <> ("#N/A") Then 'vlookup is #N/A and is causing an error2042
reportlocation = "R" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "S" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "Y" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "Z" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AF" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AG" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AH" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AI" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AJ" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AK" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AL" + m
Sheets(sh).Range(reportlocation) = strvar
Else
p = p + 1
m = p + 1
End If
p = p + 1
m = p + 1
Next cell
End Sub
Sub Input_NA()
With ActiveWorkbook
.RunAutoMacros xlAutoActivate
End With
Dim cell As Object
Dim reportlocation As String
Dim sh As String
Dim strvar As String
Dim p As Integer
Dim m As String
strvar = "N/A"
sh = "1244 HT-DOC 12"
p = p + 1
m = p + 1
For Each cell In Range("L9:L42")
If cell <> ("#N/A") Then 'vlookup is #N/A and is causing an error2042
reportlocation = "R" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "S" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "Y" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "Z" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AF" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AG" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AH" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AI" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AJ" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AK" + m
Sheets(sh).Range(reportlocation) = strvar
reportlocation = "AL" + m
Sheets(sh).Range(reportlocation) = strvar
Else
p = p + 1
m = p + 1
End If
p = p + 1
m = p + 1
Next cell
End Sub