Hi everyone.
I am having trouble trying to get a line of code to run.
What I want to do is if the tab name contains "INV" or "STM", I need to copy paste the values of columns A:D as well as A1:P1.
I am getting a "Compile error. Next without For" prompt at debug.
I don't know if my logic is wrong because I tried to troubleshoot by changing the command to hiding the columns and the debug did not turn up.
Where am I going wrong?
Would appreciate any help. Thanks in advance.
I am having trouble trying to get a line of code to run.
VBA Code:
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "*INV*" Or ws.Name Like "*STM*" Then
ws.Columns("A:D").Copy
ws.Columns("A:D").PasteSpecial Paste:=xlPasteValues
ws.Range("A1:P1").Copy
ws.Range("A1:P1").PasteSpecial Paste:=xlPasteValues
Next ws
End If
What I want to do is if the tab name contains "INV" or "STM", I need to copy paste the values of columns A:D as well as A1:P1.
I am getting a "Compile error. Next without For" prompt at debug.
I don't know if my logic is wrong because I tried to troubleshoot by changing the command to hiding the columns and the debug did not turn up.
Code:
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "*INV*" Or ws.Name Like "*STM*" Then ws.Columns("A:D").Hidden = True
Next ws
End If
Where am I going wrong?
Would appreciate any help. Thanks in advance.