473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Setting Pg breaks using VB

Hi there,

Ive got a report which runs but I need to manually set the pg breaks. Its quite a big report and its not always the same length. I need to print columns A to Q. Rows 1 to 5 are headers then I need to count down 45 rows and set pg break and keep counting down 45 rows until the end of the report. It take ages to do manually so i was hoping there might be some clever code which can do it for me.

Thanks in advance Mark
Nov 21 '11 #1

✓ answered by Guido Geurs

This will place a pagebreak each 45 rows:
Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  2. Dim PAGEBREAKidx As Integer
  3. Dim ADDRESScell As String
  4.     For PAGEBREAKidx = 1 To 10
  5.         ADDRESScell = "A" & (5 + (PAGEBREAKidx * 45))
  6.         Range(ADDRESScell).Select
  7.         ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
  8.     Next
  9. End Sub

1 1449
Guido Geurs
767 Expert 512MB
This will place a pagebreak each 45 rows:
Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  2. Dim PAGEBREAKidx As Integer
  3. Dim ADDRESScell As String
  4.     For PAGEBREAKidx = 1 To 10
  5.         ADDRESScell = "A" & (5 + (PAGEBREAKidx * 45))
  6.         Range(ADDRESScell).Select
  7.         ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
  8.     Next
  9. End Sub
Nov 21 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Eric Linders | last post by:
Hello, Our company currently processes a few hundred form submissions through our site. Up till now, the contents of the form has been sent to our customer support staff in real-time. Each...
11
by: Grant Edwards | last post by:
I'm trying in vain to set the icon for the executable generated by py2exe. According to various sources there are two answers: 1) Do it on the command line: python setup.py py2exe --icon...
4
by: G. Richard Bellamy | last post by:
I'm trying to unset the Encrypted attribute on all the files in a path. The attribute is not getting set. What am I doing wrong? Perhaps there's another newsgroup I can send this to? Here's...
12
by: daniel kaplan | last post by:
Hi All, Been learning Javascript (via google) to create forms with pre-set values. As seen below. My problem I have found is this: I can't seem to figure out (or find so far via google) how to...
15
by: tshad | last post by:
I am trying to put an persons email address in a response I am sending another person. I can get it to work by doing the following: message.Body = resumeTop & vbCrLf & vbCrLf & "For Applicant:...
2
by: dotnetjose | last post by:
Hi Folks, My subject message pretty musch explains it. By Default the Form definition sits at the Master Page file. Is there a way I can access the setting from my Content Page that uses a...
0
by: =?Utf-8?B?TGlhbSBNYWM=?= | last post by:
Hi Folks, I have embeded WMI scripting within a Visual Basic application to create remote shares and set permissions, I'm now moving to vb.net environment and having trouble getting my scripting...
4
by: Velhari | last post by:
Hi all, I wrote the following Javascript function used to execute the Javascript codes from the ajax response which contains both html & javascript. It works fine, if the javascript codes from...
7
by: fahadqureshi | last post by:
I have the following code snippet from a larger program which is working perfectly for making a gui and adding buttons to it: self.B0 = wx.Button(id=wxID_FRAME2B0, label='Choose Cases', ...
3
MusoFreak200
by: MusoFreak200 | last post by:
hi again everyone i need help in setting up (using html) a username/password for a webpage if anyone could help me please i would be greatful. thanks cya MusoFreak200
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.