| View previous topic :: View next topic |
| Author |
Message |
grkn General User

Joined: 02 Dec 2005 Posts: 29
|
Posted: Mon Dec 12, 2005 8:13 am Post subject: Newbie needs help with for loop :) |
|
|
| Code: | Sub Macro1
Dim oSheetDsc as object
Dim i as integer
Dim aRow as object
For o = 0 To 50
i = 7
'set your sheet name
oSheetDSC = ThisComponent.Sheets.getByName("Sheet1")
aRow = oSheetDsc.rows(i)
aRow.isStartOfNewPage = true
i = i + 7
o = 0 + 1
Next o
End Sub |
So, I want to make a page break after the next 7 rows, 50 times.
What's wrong with my loop?
Regards Johan, rookie |
|
| Back to top |
|
 |
Laurent Godard General User


Joined: 16 Mar 2003 Posts: 47 Location: Grenoble (France)
|
Posted: Mon Dec 12, 2005 8:29 am Post subject: |
|
|
Hi
only dealing with the loop, i would say
| Code: | For j = 1 To 50
i = j*7
'set your sheet name
oSheetDSC = ThisComponent.Sheets.getByName("Sheet1")
aRow = oSheetDsc.rows(i)
aRow.isStartOfNewPage = true
Next j |
The for loop automatically increases the variable used for the loop
avoid to use o or l as varaible names
Laurent |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8983 Location: Lexinton, Kentucky, USA
|
Posted: Mon Dec 12, 2005 11:25 am Post subject: |
|
|
| And this would be an wrong if nothing else, "o = 0 + 1". Presumably you meant, "o = o +1", which supports the advice, "avoid to use o or l as varaible names". |
|
| Back to top |
|
 |
grkn General User

Joined: 02 Dec 2005 Posts: 29
|
Posted: Mon Dec 12, 2005 11:57 am Post subject: |
|
|
| Thanks, worked like it should! |
|
| Back to top |
|
 |
Laurent Godard General User


Joined: 16 Mar 2003 Posts: 47 Location: Grenoble (France)
|
Posted: Mon Dec 12, 2005 1:00 pm Post subject: |
|
|
ok
one last point
you should move
| Code: | | oSheetDSC = ThisComponent.Sheets.getByName("Sheet1") |
outside of the loop
Laurent |
|
| Back to top |
|
 |
|