Printing selective rows

G

Guest

Guest
I have a spreadsheet with inventory data in it and I want to selectively hide rows. Essentially, I do not want rows to print that have zero in the quantity column (let's use column 1 in this example).

My thought was to create a macro that would go to A1, test it for zero, hide the row if it is zero, and go down to the next row. It should end when it comes to the word "end" in a cell.

Problem is: I don't know how to write Excel macros. Any ideas? Thanks.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You don't really need to do this via a macro. Why not use data filtering? From the main menu, select Data|Filter|AutoFilter. You can then specify to show non-zero values. If you need any help with this just let me know.

PS - you should post this question in the "Macro Questions" section since this forum is only for testing. At least that's my understanding :)
 
Upvote 0
[Y]ou should post this question in the "Macro Questions" section since this forum is only for testing. At least that's my understanding :)

I can hardly blame the OP: Cross-postings & wrong choice of category in which to post will be our biggest problem with the new board, I'm afraid, and endless space consuming remarks pointing out these 'mistakes'. Darn it, I already produced at least 3 posts regarding this issue!



Aladin
This message was edited by Aladin Akyurek on 2002-02-16 11:42
 
Upvote 0
See if this will help you...

Dim Cell As Range
Dim blnCellHasData As Boolean

For Each Cell In Range("A1:R1")
If Cell.Value = 0 Then
Rows("1:1").EntireRow.Hidden = True
Else
blnCellHasData = True
End If
Next
If blnCellHasData = False Then
Rows("1:1").EntireRow.Hidden = True
Else
Rows("1:1").EntireRow.Hidden = False
End If
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,037
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top