View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
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