Hiding everey n-th row

G

Guest

Hi,

I want to hide every n-th row from some point. I have a sheet with on every row a date. everey week is followed bij a total-row. I want to hide all the date viewing only he totals. However this has to start at row 9 (1-8 has a header). See the code, how can I make it start at row 9?

Sub HideRows()
Dim hRows As Long
Const myHidden As Long = 6
Const Jump1 As Long = 2
'Const Jump2 As Long = 2
Const LastRow As Long = 100
For hRows = 1 To LastRow Step Jump1 + myHidden
Rows(CStr(hRows + Jump1) & ":" & CStr(hRows + myHidden + Jump1)).Select
Selection.EntireRow.Hidden = True
'Rows(CStr(hRows + Jump1 + Jump2) & ":" & CStr(hRows + Jump1 + Jump2 + myHidden)).Select
'Selection.EntireRow.Hidden = True
Next hRows
End Sub
 
B

Bernie Deitrick

Someone with no name,

Sub HideRows()
Dim hRows As Long
Const myHidden As Long = 6
Const Jump1 As Long = 2
Const LastRow As Long = 100

For hRows = 9 To LastRow Step Jump1 + myHidden
Rows(CStr(hRows) & ":" & CStr(hRows + myHidden)).Hidden = True
Next hRows
End Sub

Though if you have some label such as "Total" in a column, you could
simply filter your table and only show those values labeled Total....

HTH,
Bernie


Hi,

I want to hide every n-th row from some point. I have a sheet with
on every row a date. everey week is followed bij a total-row. I want
to hide all the date viewing only he totals. However this has to start
at row 9 (1-8 has a header). See the code, how can I make it start at
row 9?
 
T

Tom Ogilvy

If it works now maybe the easiest is to do

Sub HideRows()
Dim hRows As Long
Const myHidden As Long = 6
Const Jump1 As Long = 2
'Const Jump2 As Long = 2
Const LastRow As Long = 100
For hRows = 1 To LastRow Step Jump1 + myHidden
if hRows > 8 then
Rows(CStr(hRows + Jump1) & ":" & CStr(hRows + myHidden + Jump1)).Select
Selection.EntireRow.Hidden = True
'Rows(CStr(hRows + Jump1 + Jump2) & ":" & CStr(hRows + Jump1 + Jump2 +
myHidden)).Select
'Selection.EntireRow.Hidden = True
Next
Next hRows
End Sub

Regards,
Tom Ogilvy


Hi,

I want to hide every n-th row from some point. I have a sheet with on
every row a date. everey week is followed bij a total-row. I want to hide
all the date viewing only he totals. However this has to start at row 9 (1-8
has a header). See the code, how can I make it start at row 9?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top