VBA macro to paginate worksheet

ihf

New Member
Joined
Mar 13, 2022
Messages
2
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2011
Platform
  1. Windows
  2. MacOS
I have a worksheet which has names in the first column (starting at A2). My macro sorts on that column. I now need to paginate the worksheet such that there is a page of names for each letter of the alphabet. How to do this?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I have a worksheet which has names in the first column (starting at A2). My macro sorts on that column. I now need to paginate the worksheet such that there is a page of names for each letter of the alphabet. How to do this?
To create a worksheet for each letter of the alphabet you could use this
VBA Code:
Sub test()
For ascii = 65 To 90
Sheets.Add.name = Chr(ascii)
Next ascii
End Sub
You could that in combination with a filter so that if the letter of the name appears you then copy paste create info into the relevant sheet etc or dont create if letter doesnt exist. As you havent specified if the sheets will be based on First or last names cant help you any further.
 
Upvote 0
To create a worksheet for each letter of the alphabet you could use this
VBA Code:
Sub test()
For ascii = 65 To 90
Sheets.Add.name = Chr(ascii)
Next ascii
End Sub
You could that in combination with a filter so that if the letter of the name appears you then copy paste create info into the relevant sheet etc or dont create if letter doesnt exist. As you havent specified if the sheets will be based on First or last names cant help you any further.
Thanks. That helps but what I need to do is paginate the worksheet (i.e., add page breaks) whenever the first letter of the name changes.
For example, if column a has a list of names
Aaron
Arnold
...
Betty
Boris
...
I want to end up with page breaks such that the A names are on one page, B on the next, and so on. To complicate this further I need to have the same column heading on all pages.
 
Upvote 0

Forum statistics

Threads
1,225,169
Messages
6,183,318
Members
453,155
Latest member
joncaxddd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top