this may seem a as repeated question but I am having issues with the code whereby the columns still display despite not meeting the IF condition If CBool(Application.WorksheetFunction.CountIf(.Columns(j), "<>0")) . The code loops through columns and only displays columns that has values >0. I do not know if the issue is with j or with CBool condition itself . Would need some help as I really need this code for my excel as it would be then much more easier and useful to analyse! Thank you
Sub TestPasteColumnData3()
Dim lastcol As Long
Dim j As Long
With Worksheets("WF - L12 (3)")
lastcol = .Cells(5, Columns.Count).End(xlToLeft).Column
For j = 3 To lastcol
'change >0 to <>0 and 3 to j
If CBool(Application.WorksheetFunction.CountIf(.Columns(j), "<>0")) Then
.Columns(j).Copy Destination:=Worksheets("Sheet 1").Columns(j) 'Dont delete, this code works
Else
MsgBox ("No Value")
Exit Sub
End If
Next
End With
MsgBox ("Done")
End Sub
