close

Hi,

I've recorded a macro doing the following: group all worksheets, select
file|pagesetup, and then select my formatting, etc.

The formatting was successfully applied to all worksheets at this stage.
However when I try to run the macro, the formatting is only applied to the
first worksheet.

What gives?

Thanks.

Allan

Are you Twirly?

Can you use a macro?

Option Explicit
Sub testme()
Dim wks As Worksheet
For Each wks In ActiveWindow.SelectedSheets
With wks
.PageSetup.PrintArea = quot;A1:X99quot;
End With
Next wks
End Sub

You have to group the worksheets that should have the same print area
before running the macro.

Click on the first worksheet tab and ctrl-click on subsequent.

And after, rightclick on one of the grouped sheets and select ungroup sheets.If you're new to macros, you may want to read David McRitchie's intro at:
www.mvps.org/dmcritchie/excel/getstarted.htm
KonaAl wrote:
gt;
gt; Hi,
gt;
gt; I've recorded a macro doing the following: group all worksheets, select
gt; file|pagesetup, and then select my formatting, etc.
gt;
gt; The formatting was successfully applied to all worksheets at this stage.
gt; However when I try to run the macro, the formatting is only applied to the
gt; first worksheet.
gt;
gt; What gives?
gt;
gt; Thanks.
gt;
gt; Allan

--

Dave Peterson

Thanks so much Dave! -- works perfectly.

I'm not Twirly -- assuming that's a person! I'm familiar with macros but
the whole for:next thing had me stumped when I looked through the help files.

Thanks again.

Allan

quot;Dave Petersonquot; wrote:

gt; Are you Twirly?
gt;
gt; Can you use a macro?
gt;
gt; Option Explicit
gt; Sub testme()
gt; Dim wks As Worksheet
gt; For Each wks In ActiveWindow.SelectedSheets
gt; With wks
gt; .PageSetup.PrintArea = quot;A1:X99quot;
gt; End With
gt; Next wks
gt; End Sub
gt;
gt; You have to group the worksheets that should have the same print area
gt; before running the macro.
gt;
gt; Click on the first worksheet tab and ctrl-click on subsequent.
gt;
gt; And after, rightclick on one of the grouped sheets and select ungroup sheets.
gt;
gt;
gt; If you're new to macros, you may want to read David McRitchie's intro at:
gt; www.mvps.org/dmcritchie/excel/getstarted.htm
gt;
gt;
gt;
gt; KonaAl wrote:
gt; gt;
gt; gt; Hi,
gt; gt;
gt; gt; I've recorded a macro doing the following: group all worksheets, select
gt; gt; file|pagesetup, and then select my formatting, etc.
gt; gt;
gt; gt; The formatting was successfully applied to all worksheets at this stage.
gt; gt; However when I try to run the macro, the formatting is only applied to the
gt; gt; first worksheet.
gt; gt;
gt; gt; What gives?
gt; gt;
gt; gt; Thanks.
gt; gt;
gt; gt; Allan
gt;
gt; --
gt;
gt; Dave Peterson
gt;

Twirly(?) asked a very similar question just moments before you did. In fact, I
essentially copied and pasted my reply.

KonaAl wrote:
gt;
gt; Thanks so much Dave! -- works perfectly.
gt;
gt; I'm not Twirly -- assuming that's a person! I'm familiar with macros but
gt; the whole for:next thing had me stumped when I looked through the help files.
gt;
gt; Thanks again.
gt;
gt; Allan
gt;
gt; quot;Dave Petersonquot; wrote:
gt;
gt; gt; Are you Twirly?
gt; gt;
gt; gt; Can you use a macro?
gt; gt;
gt; gt; Option Explicit
gt; gt; Sub testme()
gt; gt; Dim wks As Worksheet
gt; gt; For Each wks In ActiveWindow.SelectedSheets
gt; gt; With wks
gt; gt; .PageSetup.PrintArea = quot;A1:X99quot;
gt; gt; End With
gt; gt; Next wks
gt; gt; End Sub
gt; gt;
gt; gt; You have to group the worksheets that should have the same print area
gt; gt; before running the macro.
gt; gt;
gt; gt; Click on the first worksheet tab and ctrl-click on subsequent.
gt; gt;
gt; gt; And after, rightclick on one of the grouped sheets and select ungroup sheets.
gt; gt;
gt; gt;
gt; gt; If you're new to macros, you may want to read David McRitchie's intro at:
gt; gt; www.mvps.org/dmcritchie/excel/getstarted.htm
gt; gt;
gt; gt;
gt; gt;
gt; gt; KonaAl wrote:
gt; gt; gt;
gt; gt; gt; Hi,
gt; gt; gt;
gt; gt; gt; I've recorded a macro doing the following: group all worksheets, select
gt; gt; gt; file|pagesetup, and then select my formatting, etc.
gt; gt; gt;
gt; gt; gt; The formatting was successfully applied to all worksheets at this stage.
gt; gt; gt; However when I try to run the macro, the formatting is only applied to the
gt; gt; gt; first worksheet.
gt; gt; gt;
gt; gt; gt; What gives?
gt; gt; gt;
gt; gt; gt; Thanks.
gt; gt; gt;
gt; gt; gt; Allan
gt; gt;
gt; gt; --
gt; gt;
gt; gt; Dave Peterson
gt; gt;

--

Dave Peterson

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()