Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 72
Default How do I write an array to include all worksheets in a workbook?

I am trying to add to a marco to auto fit columns A through H in all
worksheets. How would I add this so it does not matter how many tabs are in
the workbook as it will continually change?
--
Thank you, Jodie
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default How do I write an array to include all worksheets in a workbook?

hi,

Right click any of your sheet tab, view code and paste this code in and run it

Sub sonic()
For x = 1 To Worksheets.Count
Sheets(x).Columns("A:H").AutoFit
Next
End Sub

Mike

"Jodie" wrote:

I am trying to add to a marco to auto fit columns A through H in all
worksheets. How would I add this so it does not matter how many tabs are in
the workbook as it will continually change?
--
Thank you, Jodie

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 563
Default How do I write an array to include all worksheets in a workbook?

Just out of interest, why did you suggest making this a sheet subroutine
rather than putting it in a general module?
best wsihes

--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"Mike H" wrote in message
...
hi,

Right click any of your sheet tab, view code and paste this code in and
run it

Sub sonic()
For x = 1 To Worksheets.Count
Sheets(x).Columns("A:H").AutoFit
Next
End Sub

Mike

"Jodie" wrote:

I am trying to add to a marco to auto fit columns A through H in all
worksheets. How would I add this so it does not matter how many tabs are
in
the workbook as it will continually change?
--
Thank you, Jodie


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default How do I write an array to include all worksheets in a workboo

Bernard,

Several reasons:-

It will work

I guess (and apologise to the OP if i'm wrong) that the OP is very
inexperienced and entering worksheet code utilises less steps than entering a
general module. Three mouse mouse clicks and the code is in.

It's my habit and preferred way of doing it 'provided' I'm not reading from
or writing to sheets other than the one that contains the code. Although
there's no reason why worksheet code couldn't work too if doing that.

I'm aware of the convention that worksheet modules are for event code but
have never heard a compelling argument that it's anything other than that, 'a
convention'.

Mike



"Bernard Liengme" wrote:

Just out of interest, why did you suggest making this a sheet subroutine
rather than putting it in a general module?
best wsihes

--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"Mike H" wrote in message
...
hi,

Right click any of your sheet tab, view code and paste this code in and
run it

Sub sonic()
For x = 1 To Worksheets.Count
Sheets(x).Columns("A:H").AutoFit
Next
End Sub

Mike

"Jodie" wrote:

I am trying to add to a marco to auto fit columns A through H in all
worksheets. How would I add this so it does not matter how many tabs are
in
the workbook as it will continually change?
--
Thank you, Jodie



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default How do I write an array to include all worksheets in a workboo



Several reasons:-

It will work


.... unless some innocent user deletes this special purpose sheet with
the implicit general functionality.

Why not just say 1. Press ALT + F11 2. Insert a new module 3. Copy the
code into the new module 4. Go back to worksheet and use it?

Regards,
Bernd


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default How do I write an array to include all worksheets in a workboo

As stated

It's my habit and preferred way of doing it 'provided' I'm not reading from
or writing to sheets other than the one that contains the code. Although
there's no reason why worksheet code couldn't work too if doing that

If you believe this is fundamentally incorrect provide a compelling argument
as to why.

Before you reply consider why Microsoft provide a 'general' option in the
dropdown of worksheet modules if entering something other than event code is
inappropriate.

Mike

"Bernd P" wrote:



Several reasons:-

It will work


.... unless some innocent user deletes this special purpose sheet with
the implicit general functionality.

Why not just say 1. Press ALT + F11 2. Insert a new module 3. Copy the
code into the new module 4. Go back to worksheet and use it?

Regards,
Bernd

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 563
Default How do I write an array to include all worksheets in a workboo

Good to know
Bernard

"Mike H" wrote in message
...
Bernard,

Several reasons:-

It will work

I guess (and apologise to the OP if i'm wrong) that the OP is very
inexperienced and entering worksheet code utilises less steps than
entering a
general module. Three mouse mouse clicks and the code is in.

It's my habit and preferred way of doing it 'provided' I'm not reading
from
or writing to sheets other than the one that contains the code. Although
there's no reason why worksheet code couldn't work too if doing that.

I'm aware of the convention that worksheet modules are for event code but
have never heard a compelling argument that it's anything other than that,
'a
convention'.

Mike



"Bernard Liengme" wrote:

Just out of interest, why did you suggest making this a sheet subroutine
rather than putting it in a general module?
best wsihes

--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"Mike H" wrote in message
...
hi,

Right click any of your sheet tab, view code and paste this code in and
run it

Sub sonic()
For x = 1 To Worksheets.Count
Sheets(x).Columns("A:H").AutoFit
Next
End Sub

Mike

"Jodie" wrote:

I am trying to add to a marco to auto fit columns A through H in all
worksheets. How would I add this so it does not matter how many tabs
are
in
the workbook as it will continually change?
--
Thank you, Jodie



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I include multiple worksheets to a countif formula? Brigette Excel Discussion (Misc queries) 1 August 19th 09 10:58 PM
Pivot Table - include multiple worksheets with different ranges. Tracy Excel Discussion (Misc queries) 1 December 13th 07 06:27 PM
Formula needs to include several worksheet tabs in one workbook klafert Excel Discussion (Misc queries) 12 July 2nd 07 02:16 PM
include criteria to 'rank based array function' TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 September 2nd 06 01:15 PM
How do i include the original workbook in the email message creat. ebxr8 Excel Discussion (Misc queries) 4 April 9th 05 12:25 AM


All times are GMT +1. The time now is 02:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"