Hide Column if Grand Total is 0

  • Thread starter Thread starter serhat
  • Start date Start date
S

serhat

I have a macro that subtotals based on sales order. If a column (e.
price adjustment) has a Grand Total value of 0 I hide the column befor
printing the report.

Is there a macro that could search for the word Grand Total then
go to each column starting from H through T on the Grand Total Row, se
if the value is 0 and hide the column if the value is 0.

Any help will be greatly appreciated.

S
 
Hi,
Try something like:

Sub HideGT()
For Each c In Range(Cells(1, "A"), Cells(ActiveCell.End
(xlDown).Row, "A"))
If UCase(c.Value) = "GRAND TOTAL" Then
For Each d In Range(Cells(c.Row, "H"), Cells
(c.Row, "T"))
If d.Value = 0 Then
Columns(d.Column).Select
Selection.EntireColumn.Hidden = True
End If
Next d
Exit Sub
End If
Next c
End Sub

jeff
 
Thanks Jeff. I had to add to the macro to rename Grand Total to a numbe
run your code adn then rename it bak to Grand Total to get it to work.

I really appreciate your help
 
Back
Top