Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I include multiple worksheets to a countif formula? | Excel Discussion (Misc queries) | |||
Pivot Table - include multiple worksheets with different ranges. | Excel Discussion (Misc queries) | |||
Formula needs to include several worksheet tabs in one workbook | Excel Discussion (Misc queries) | |||
include criteria to 'rank based array function' | Excel Discussion (Misc queries) | |||
How do i include the original workbook in the email message creat. | Excel Discussion (Misc queries) |