Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hiding Rows in Excel with VBA

I am not sure if this requires VBA but I am working in Excel 2K and we need some simple code that (1) will hide a row if a zero appears in the column J of that row. Or alternatively (2 and to attach it to a button to be activated, code that will hide any row in a table range that shows a zero in column J for the range of the table (let's say from Rows A1:J25). If both of these are possible I would like to see sample code that would accomplish this. Can anyone help us get started? - we know how to write the code for the rest of our steps. This one has us a bit stuck.

Thanks!
Dave

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Hiding Rows in Excel with VBA

David

Right-click on the sheet in which you want this to run and
select the View Code option from the pop-up menu.

Paste in the following code

Presumably you will want to unhide the rows prior to
updating the sheet.

Sub UnhideRows()
Dim rng As Range
Set rng = Range("J1:J25")
'Make sure that nothing is hidden
rng.Select
Selection.EntireRow.Hidden = False
End Sub

Sub HideRows()
Dim rng As Range
Set rng = Range("J1:J25")
'Make sure that nothing is hidden
rng.Select
Selection.EntireRow.Hidden = False
For Each c In rng
c.Select
If c.Value = 0 Then
Selection.EntireRow.Hidden = True
Else
Selection.EntireRow.Hidden = False
End If
Next c
End Sub


-----Original Message-----
I am not sure if this requires VBA but I am working in

Excel 2K and we need some simple code that (1) will hide a
row if a zero appears in the column J of that row. Or
alternatively (2 and to attach it to a button to be
activated, code that will hide any row in a table range
that shows a zero in column J for the range of the table
(let's say from Rows A1:J25). If both of these are
possible I would like to see sample code that would
accomplish this. Can anyone help us get started? - we know
how to write the code for the rest of our steps. This one
has us a bit stuck.

Thanks!
Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Hiding Rows in Excel with VBA

Dim cell as Range
Range("1:25").EntireRow.Hidden = False
for each cell in Range("J1:J25")
if isnumeric(cell) and not isempty(cell) then
if cell.Value = 0 then
cell.Entirerow.Hidden = True
end if
end if
Next


Dim rng as Range
set rng = Cells(ActiveCell.Row,"J")
if isnumeric(rng) and not isempty(rng) then
if rng.value = 0 then
rng.Entirerow.Hidden = True
end if
end if

--
Regards,
Tom Ogilvy



David Spiteri wrote in message
...
I am not sure if this requires VBA but I am working in Excel 2K and we need
some simple code that (1) will hide a row if a zero appears in the column J
of that row. Or alternatively (2 and to attach it to a button to be
activated, code that will hide any row in a table range that shows a zero in
column J for the range of the table (let's say from Rows A1:J25). If both of
these are possible I would like to see sample code that would accomplish
this. Can anyone help us get started? - we know how to write the code for
the rest of our steps. This one has us a bit stuck.

Thanks!
Dave


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
Excel keeps hiding some of my rows JohnT Excel Discussion (Misc queries) 0 January 10th 11 11:37 AM
Hiding rows in Excel 2007 Paul Excel Discussion (Misc queries) 0 April 23rd 09 11:42 PM
Excel hiding rows debs Excel Discussion (Misc queries) 3 September 12th 06 08:17 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
Hiding Rows in EXCEL (Conditionally) Paul B[_6_] Excel Programming 0 September 14th 03 03:03 AM


All times are GMT +1. The time now is 12:05 AM.

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

About Us

"It's about Microsoft Excel"