#1   Report Post  
Macro to hide rows in spreadwsheet
 
Posts: n/a
Default hide rows with macro

i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,
  #2   Report Post  
CLR
 
Posts: n/a
Default

You can do this with the Autofilter............whether you want to delete
rows with one zero or two, or whatever........

Data Filter AutoFilter Custom "does not equal" 0.........then if
you want to further massage that result, just copy and paste it over to
another worksheet............

Vaya con Dios,
Chuck, CABGx3



"Macro to hide rows in spreadwsheet" <Macro to hide rows in spreadwsheet
@discussions.microsoft.com wrote in message
...
i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col

b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,



  #3   Report Post  
JE McGimpsey
 
Posts: n/a
Default

You give conflicting criteria - "both cells contain zeros" and "col b or
col c is zero"

Which do you mean?

In article ,
"Macro to hide rows in spreadwsheet" <Macro to hide rows in
spreadwsheet @discussions.microsoft.com wrote:

i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,

  #4   Report Post  
B.S.R.
 
Posts: n/a
Default

I've done this before by putting a formula in a column in the spreadsheet to
evaluate whether or not the row should be hidden, then referencing that
column in the code.

So let's say you put this formula in column "Q":

=IF(AND(B49=0,C49=0),"Y","N")

Then in your macro:

For rowNum = 49 To 778
If Range("Q" & rowNum) = "Y" Then
Range("Q" & rowNum).Select
Selection.EntireRow.Hidden = True
End If
Next rowNum

Make sure you unhide all the rows before calculating the sheet and running
this macro.

"JE McGimpsey" wrote:

You give conflicting criteria - "both cells contain zeros" and "col b or
col c is zero"

Which do you mean?

In article ,
"Macro to hide rows in spreadwsheet" <Macro to hide rows in
spreadwsheet @discussions.microsoft.com wrote:

i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to hide rows david Excel Discussion (Misc queries) 3 April 8th 05 03:25 PM
inset rows and copy formatting , excel macro sloanranger Excel Discussion (Misc queries) 13 March 9th 05 11:44 PM
how to hide rows in a protected sheet Prakash Excel Worksheet Functions 7 January 18th 05 02:42 PM
Macro to hide rows with empty cells tp58tp Excel Worksheet Functions 2 November 13th 04 02:01 PM
Macro for sorting different rows ciscopena Excel Worksheet Functions 0 November 1st 04 11:04 PM


All times are GMT +1. The time now is 09:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"