#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default LastCell

I want to loop through rows first to make sure they are all unhidden, then I
want to hide rows that have "yes" in a cell. This doesn't work because the
xlCellTypeLastCell goes to the last visible cell. So if the last cell had
"yes" in it, it would have been hidden and my code won't unhide it. I dont'
know how to fix it.

Hope I explained this.

Thanks,

Private Sub CAT()
Dim i As Long

For i = 1 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastC ell).Row

If Cells(i, 2).Rows(i).Hidden = True Then
Cells(i, 2).Rows(i).Hidden = False

ElseIf Cells(i, 2).Value = "Yes" Then
Rows(i).EntireRow.Hidden = True
End If

Next i
End Sub
--
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default LastCell

I'm sure there are other ways, but you can add this to the top of your code
to unhide all columns and rows.

With Cells
.Rows.Hidden = False
.Columns.Hidden = False
End With


"Howard" wrote in message
...
I want to loop through rows first to make sure they are all unhidden, then
I
want to hide rows that have "yes" in a cell. This doesn't work because the
xlCellTypeLastCell goes to the last visible cell. So if the last cell had
"yes" in it, it would have been hidden and my code won't unhide it. I
dont'
know how to fix it.

Hope I explained this.

Thanks,

Private Sub CAT()
Dim i As Long

For i = 1 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastC ell).Row

If Cells(i, 2).Rows(i).Hidden = True Then
Cells(i, 2).Rows(i).Hidden = False

ElseIf Cells(i, 2).Value = "Yes" Then
Rows(i).EntireRow.Hidden = True
End If

Next i
End Sub
--
Howard



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default LastCell

Try it in two steps:

1. make sure ALL rows are unhidden:
Cells.EntireRow.Hidden = False

2. run the logic to hide what you want

--
Gary''s Student
gsnu200709


"Howard" wrote:

I want to loop through rows first to make sure they are all unhidden, then I
want to hide rows that have "yes" in a cell. This doesn't work because the
xlCellTypeLastCell goes to the last visible cell. So if the last cell had
"yes" in it, it would have been hidden and my code won't unhide it. I dont'
know how to fix it.

Hope I explained this.

Thanks,

Private Sub CAT()
Dim i As Long

For i = 1 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastC ell).Row

If Cells(i, 2).Rows(i).Hidden = True Then
Cells(i, 2).Rows(i).Hidden = False

ElseIf Cells(i, 2).Value = "Yes" Then
Rows(i).EntireRow.Hidden = True
End If

Next i
End Sub
--
Howard

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 2007 BUG UsedRange/LastCell differences with Excel2003. keepITcool Excel Discussion (Misc queries) 2 May 31st 06 06:18 PM
lastcell in thiscolumn function error deano Excel Programming 5 December 1st 05 07:45 PM
Dynamic LastCell James Agostinho Excel Programming 4 February 22nd 04 09:08 PM
LastCell Function David Excel Programming 6 December 5th 03 02:51 PM


All times are GMT +1. The time now is 01:42 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"