Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro hide rows with blank data in cells

Hello. Can anyone help?

I need a simple macro that looks down column E to find the last row
with data in it (say row 118) and then goes from 10 to 118 looking in
column G hiding the row if there's no data in the cell. I've tried
but with no luck, can anyone help? There must be many ways to do this
but KISS is the best...

Matt.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Macro hide rows with blank data in cells

Sub Hiderows()
Dim iLastrow As Integer
'This is your last row in col a
iLastrow = Range("A65536").End(xlUp).Row
For i = 1 To iLastrow
If Cells(i, 1) = "" Then
Cells(i, 1).EntireRow.Hidden = True
End If
Next i


End Sub
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




" wrote:

Hello. Can anyone help?

I need a simple macro that looks down column E to find the last row
with data in it (say row 118) and then goes from 10 to 118 looking in
column G hiding the row if there's no data in the cell. I've tried
but with no luck, can anyone help? There must be many ways to do this
but KISS is the best...

Matt.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro hide rows with blank data in cells

I just need a way now to figure out the last cell in Column E that has
data so I don't go all the way to the bottom to replace the "118" to
allow for varied length charts.

Sub HideBlankSales()
Dim X As Integer
For X = 10 To 118

If Cells(X, 7).Value = 0 Then
Rows(X).Hidden = True
Else
Rows(X).Hidden = False
End If
Next X
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Macro hide rows with blank data in cells

Dim BotRow as Long
BotRow=Range("E65536").End(xlUp).Row
For X = 10 To BotRow

HTH
wrote:
I just need a way now to figure out the last cell in Column E that has
data so I don't go all the way to the bottom to replace the "118" to
allow for varied length charts.

Sub HideBlankSales()
Dim X As Integer
For X = 10 To 118

If Cells(X, 7).Value = 0 Then
Rows(X).Hidden = True
Else
Rows(X).Hidden = False
End If
Next X
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Macro hide rows with blank data in cells

Change the A to in on the following statement:
iLastrow = Range("A65536").End(xlUp).Row
so it looks like this:
iLastrow = Range("E65536").End(xlUp).Row

Then change the 1 in Cells(i,1) to Cells(i,5)
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




" wrote:

I just need a way now to figure out the last cell in Column E that has
data so I don't go all the way to the bottom to replace the "118" to
allow for varied length charts.

Sub HideBlankSales()
Dim X As Integer
For X = 10 To 118

If Cells(X, 7).Value = 0 Then
Rows(X).Hidden = True
Else
Rows(X).Hidden = False
End If
Next X
End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro hide rows with blank data in cells

Thanks, the final code is below but if there is a better way or faster
to achieve the same result let me know. the data could go all the way
to ~5000 rows...

Sub HideBlankSales()

Dim X As Integer
Dim BotRow As Long
BotRow = Range("E65536").End(xlUp).Row

For X = 10 To BotRow
If Cells(X, 7).Value = 0 Then
Rows(X).Hidden = True
Else
Rows(X).Hidden = False
End If

Next X

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro hide rows with blank data in cells

I tried using "Application.ScreenUpdating = False" to speed things up
but it still took 25 secs. Then I found this code and it only took 3
secs, this is an example that was previously posted...

Sub HideBlankRowsInCol()
Dim myRg As Range

Set myRg = Range([e7], [e65536].End(xlUp))

On Error Resume Next
Set myRg = myRg.Offset(0, 2).SpecialCells(xlCellTypeBlanks)
If Err = 0 Then
myRg.EntireRow.Hidden = True
Else
MsgBox "No blanks"
End If
Set myRg = Nothing
End Sub

Which I could just simplify to

Sub HideBlankRowsInCol()
Dim myRg As Range
Set myRg = Range([e7], [e65536].End(xlUp))
Set myRg = myRg.Offset(0, 2).SpecialCells(xlCellTypeBlanks)
myRg.EntireRow.Hidden = True
End Sub

This code works great and I've learnt a little... Thanks for the help
HTH. Did you know of this method?

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 blank rows JForsyth Excel Worksheet Functions 6 June 5th 09 04:51 PM
Macro to hide blank rows Alan Smith Excel Programming 3 February 23rd 07 04:35 PM
Hide rows of cells that are blank dford Excel Discussion (Misc queries) 9 February 4th 07 11:35 PM
macro to hide rows if cell is blank Shooter Excel Worksheet Functions 3 September 28th 05 10:55 PM
Hide columns & rows that contain "0" or blank in a range of cells lw new guest Excel Worksheet Functions 0 August 18th 05 04:27 PM


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