hello
i am trying to hide/unhide every 3 row between rows 2 to 20.
[VBA]
Dim i As Integer
For i = 1 To 20 Step 3
If Rows(i).ishidden = True Then
Rows(i).ishidden = False
else
rows(i).ishidden=true
End If
Next i
[/VBA]
hello
i am trying to hide/unhide every 3 row between rows 2 to 20.
[VBA]
Dim i As Integer
For i = 1 To 20 Step 3
If Rows(i).ishidden = True Then
Rows(i).ishidden = False
else
rows(i).ishidden=true
End If
Next i
[/VBA]
moshe
[vba]
Dim i As Integer
For i = 1 To 20 Step 3
Rows(i).Visible = Not Rows(i).Visible
Next i
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
it failed in my excel
moshe
sorry
what about:
[VBA]
On Error Resume Next
Dim i As Integer
For i = 2 To 15 Step 2
Rows(i).Hidden = Not Rows(i).Hidden
Next i
[/VBA]
moshe
That will teach me to test it
[vba]
Dim i As Integer
For i = 1 To 20 Step 3
Rows(i).Hidden = Not Rows(i).Hidden
Next i
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
hello
this is a general version.is there any thing you can suggest to improve it?
[VBA]
On Error Resume Next
Dim i As Integer
Dim sts As Integer
Dim enr As Integer
Dim itr As Integer
sts = Application.InputBox("start row", "begin where", , , , , , 2)
enr = Application.InputBox("end where", "stop", , , , , , 2)
itr = Application.InputBox("each of everyrow?", "interval", , , , , , 2)
For i = 2 To 15 Step 2
Rows(i).Hidden = Not Rows(i).Hidden
Next i
[/VBA]
can i symplfy the variable definition & the inputbox?
thanks
moshe
It is a bit short to look for improvements, but you do declare variables and set them up but do not use them (more code that we don't see?).
Also, you declare Integer variables, it is better to use Long than Integer.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
so can you suggest alternative neat approach for writting this code?
moshe
I think the gist of my answer is that there is nothing there to get one's teeth into, so no I can't.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber