Hide Column if Grand Total is 0

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
 
J

jeff

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
 
S

serhat

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top