Getting an error with my vba
I'm trying to have the macro loop through a list, and when a row has something other than 0 in column 12, I want it to copy the information in the first column of that row, and paste it onto a different worksheet in the same workbook.
I'm getting the error message on the 'Cells(1, x).Value.Copy' part.
Sub filter()
letter = Worksheets("Variables").Range("B23").Value
x = 2
Worksheets("ER Data").Select
Do While Cells(1, x).Value <> ""
If Cells(12, x).Value <> 0 Then
Cells(1, x).Value.Copy
Sheets("Letter").Select
Range("B10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,_
SkipBlanks:=False, Transpose:=False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF,_
Filename:=Trim(letter), Quality:=xlQualityStandard,_
IncludeDocProperties:=True,IgnorePrintAreas:=False,OpenAfterPublish:=False
x = x + 1
Else
x = x + 1
End If
Loop
End Sub
I'd like it to copy and paste as desired.
.valueCells. If you useCells(12, 1)then that's cell A12 and not cell L1. Also, you never switch back to the "ER Data" sheet after copying an entry to the "Letter" sheet