Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Hiding rows programmatically

I would like to be able to hide consecutive rows in a workbook when the first row has the word Formula in Column A. The row with the word Formula in it will be contiguous with Data above it and may or may not have Rows with Data directly below it.
If possible, I would like to be able to unhide them as well. All such set of rows on a worksheet (there may be more than one Row starting with Formula per sheet) can be hidden and unhidden at the same time.

Any help would be greatly appreciated.

tj
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Hiding rows programmatically

Most of the code is from the help example for FindNext

dim c as Range, rng as Range
dim firstaddress as string
With Worksheets(1)
.Range(.Cells(1,1),.Cells(rows.count,1).end(xlup))
End with
with rng
Set c = .Find("Formula", lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if isempty(c.offset(1,0)) then
c.Entirerow.Hidden = True
else
range(c,c.end(xldown)).EntireRow.Hidden = True
end if
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
Regards,
Tom Ogilvy


"tjtjjtjt" wrote in message
...
I would like to be able to hide consecutive rows in a workbook when the

first row has the word Formula in Column A. The row with the word Formula in
it will be contiguous with Data above it and may or may not have Rows with
Data directly below it.
If possible, I would like to be able to unhide them as well. All such set

of rows on a worksheet (there may be more than one Row starting with Formula
per sheet) can be hidden and unhidden at the same time.

Any help would be greatly appreciated.

tj



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Hiding rows programmatically

Thanks!

tj

"Tom Ogilvy" wrote:

Most of the code is from the help example for FindNext

dim c as Range, rng as Range
dim firstaddress as string
With Worksheets(1)
.Range(.Cells(1,1),.Cells(rows.count,1).end(xlup))
End with
with rng
Set c = .Find("Formula", lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if isempty(c.offset(1,0)) then
c.Entirerow.Hidden = True
else
range(c,c.end(xldown)).EntireRow.Hidden = True
end if
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
Regards,
Tom Ogilvy


"tjtjjtjt" wrote in message
...
I would like to be able to hide consecutive rows in a workbook when the

first row has the word Formula in Column A. The row with the word Formula in
it will be contiguous with Data above it and may or may not have Rows with
Data directly below it.
If possible, I would like to be able to unhide them as well. All such set

of rows on a worksheet (there may be more than one Row starting with Formula
per sheet) can be hidden and unhidden at the same time.

Any help would be greatly appreciated.

tj




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
How can I delete rows programmatically based on certain criteria? nt_artagnian[_2_] New Users to Excel 2 March 8th 07 03:56 AM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
Deleting rows programmatically David Bateman Excel Worksheet Functions 1 March 6th 05 02:10 AM
Selecting Rows Programmatically Aaron Lampkin Excel Programming 1 September 5th 03 01:42 PM
Sorting rows programmatically Michael Monteiro Excel Programming 1 September 3rd 03 03:52 PM


All times are GMT +1. The time now is 07:35 PM.

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"