Hi currently, i want to hide column in my excel based on their column header. This is the code i came out but it keep hit error at line Cells(1,col).entirecolumn.hidden . It hit error hidden method of range class failed
VBA Code:
[/B]
Dim col as long, lastcol as long , header as string
lastcol = cells(1,columns.count).end(xltoleft).column
for col=lastcol to 1 step -1
header = cells(1,col).value
If (header = "Bene name") or (header ="Date") or (header = "Acc No") or (header = "GST")then
cells(1,col).entirecolumn.hidden
end if
next col
[B]