Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Hiding rows based on cell content

I need to know if there is any way (other then VB code which I already use)
to hide a row of a spreadsheet depending on the contents of a cell. I have
a spreadsheet that calculates commissions on data imported fromn Quick
Books. SOme employees do not get commissioned on all the items imported.
If a particular line item is non-commissionable I want that line to be
hidden before printing. I am presently using VB code to hide the rows but
it takes a couple of minutes to act on a 1000 row spreadsheet.

Dave


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hiding rows based on cell content

Hi Brutus.

it takes a couple of minutes to act on a 1000 row spreadsheet.


On the face of it, that would seem excessively long. Post the code that you
are using.

I need to know if there is any way (other then VB code which I already use)


Consider using the built in autofilter feature.


---
Regards,
Norman



"brutus" wrote in message
k.net...
I need to know if there is any way (other then VB code which I already use)
to hide a row of a spreadsheet depending on the contents of a cell. I have
a spreadsheet that calculates commissions on data imported fromn Quick
Books. SOme employees do not get commissioned on all the items imported.
If a particular line item is non-commissionable I want that line to be
hidden before printing. I am presently using VB code to hide the rows but
it takes a couple of minutes to act on a 1000 row spreadsheet.

Dave



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Hiding rows based on cell content


"Norman Jones" wrote in message
...
Hi Brutus.

it takes a couple of minutes to act on a 1000 row spreadsheet.


On the face of it, that would seem excessively long. Post the code that
you are using.

I need to know if there is any way (other then VB code which I already
use)


Consider using the built in autofilter feature.


---
Regards,
Norman


Sub HURows()
BeginRow = 1
EndRow = 1200
ChkCol = 16

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 4 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 2 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 5 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub

Dave


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hiding rows based on cell content

Hi Brutus,

Try this adaptation:

'===========
Sub HURows()
Dim BeginRow As Long
Dim EndRow As Long
Dim ChkCol As Long
Dim calcmode As Long

BeginRow = 1
EndRow = 1200
ChkCol = 16

ActiveSheet.DisplayPageBreaks = False

With Application
.ScreenUpdating = True
calcmode = .Calculation
.Calculation = xlManual
End With
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 4 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 2 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 5 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt

With Application
.ScreenUpdating = True
.Calculation = calcmode
End With

End Sub
'<<===========


---
Regards,
Norman



"brutus" wrote in message
k.net...

"Norman Jones" wrote in message
...
Hi Brutus.

it takes a couple of minutes to act on a 1000 row spreadsheet.


On the face of it, that would seem excessively long. Post the code that
you are using.

I need to know if there is any way (other then VB code which I already
use)


Consider using the built in autofilter feature.


---
Regards,
Norman


Sub HURows()
BeginRow = 1
EndRow = 1200
ChkCol = 16

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 4 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 2 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 5 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub

Dave



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hiding rows based on cell content

Hi Brutus,

The initial code section:

ActiveSheet.DisplayPageBreaks = False

With Application
.ScreenUpdating = True


Should read:

ActiveSheet.DisplayPageBreaks = False

With Application
.ScreenUpdating = False


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Brutus,

Try this adaptation:

'===========
Sub HURows()
Dim BeginRow As Long
Dim EndRow As Long
Dim ChkCol As Long
Dim calcmode As Long

BeginRow = 1
EndRow = 1200
ChkCol = 16

ActiveSheet.DisplayPageBreaks = False

With Application
.ScreenUpdating = True
calcmode = .Calculation
.Calculation = xlManual
End With
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 4 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 2 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 5 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt

With Application
.ScreenUpdating = True
.Calculation = calcmode
End With

End Sub
'<<===========


---
Regards,
Norman





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Hiding rows based on cell content


"Norman Jones" wrote in message
...
Hi Brutus,

The initial code section:

ActiveSheet.DisplayPageBreaks = False

With Application
.ScreenUpdating = True


Should read:

ActiveSheet.DisplayPageBreaks = False

With Application
.ScreenUpdating = False


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Brutus,

Try this adaptation:

'===========
Sub HURows()
Dim BeginRow As Long
Dim EndRow As Long
Dim ChkCol As Long
Dim calcmode As Long

BeginRow = 1
EndRow = 1200
ChkCol = 16

ActiveSheet.DisplayPageBreaks = False

With Application
.ScreenUpdating = True
calcmode = .Calculation
.Calculation = xlManual
End With
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 4 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 2 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 5 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt

With Application
.ScreenUpdating = True
.Calculation = calcmode
End With

End Sub
'<<===========


---
Regards,
Norman


Norman - Worked fine! I had to tell it to start at row 16 (the first 15
didn't contain data that needed to be hidden). Yours completes the task in
about a second. Excellent.

Thaks for your help!

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
Hiding rows based on a cell? OX_Gambit Excel Worksheet Functions 3 July 10th 09 03:05 AM
Hiding rows based value of cell within row Legion_c18 Excel Discussion (Misc queries) 0 February 22nd 08 06:01 AM
Copy rows based on cell content billinr Excel Discussion (Misc queries) 2 February 14th 07 08:17 PM
hiding rows based on cell contents Jason M Excel Discussion (Misc queries) 1 October 30th 06 04:30 PM
Hiding rows based on cell content alistair01[_4_] Excel Programming 2 February 3rd 04 01:58 PM


All times are GMT +1. The time now is 02:56 PM.

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"