Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Set column widths to match specified sheet

Hi,

I am would like to write some code to set the column width of all selected
worksheets to match the column widths in a specified sheet. Does anyone know
of any existing code or an add-in (free) that does this?

I often use multipage workbooks and can easily set the columns on all sheets
to be the same on all sheets by selecting all sheets and changing the column
width. Problems arise when the columns are later changed and I find myself
forever resetting the column widths.

Any assistance would be appreciated.

Regards.

Sean


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Set column widths to match specified sheet


Good morning Sean Bartleet

I have a free add-in available to anyone requesting it which wil
(amongst other things) copy and paste cell widths across files. If yo
would like this please send me an e-mail.

HTH

DominicB

--
dominic
-----------------------------------------------------------------------
dominicb's Profile:
http://www.excelforum.com/member.php...fo&userid=1893
View this thread: http://www.excelforum.com/showthread.php?threadid=48461

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Set column widths to match specified sheet


Hello Sean,

Dominic kindly offered you his Add-in in reponse to one part of your
request. I am offering the you the code portion in response to the
second half of your request.

This macro will ask you if you want to apply the active sheet's column
widths to the other sheets in the workbook. If the answer is No, it
does nothing. Insert a VBA module into your project and copy this code
into. You can run the macro from the Macro List (use ALT + F8 to bring
up the list).


Code:
--------------------
Public Sub SetColumnWidths()

Dim Answer, Col, Sht
Dim MasterRng As Range
Dim MasterSht As String
Dim Msg As String

Msg = "Do you want to apply this Worksheet's" & vbCrLf _
& "Column Widths to all the Worksheets?"
Answer = MsgBox(Msg, vbInformation + vbYesNo)
If Answer = vbNo Then Exit Sub

MasterSht = ActiveSheet.Name
Set MasterRng = ActiveSheet.Range("A1", "IV1")

For Each Sht In Worksheets
If Sht.Name < MasterSht Then
For Each Col In MasterRng
Sht.Range(Col.Address).ColumnWidth = Col.ColumnWidth
Next Col
End If
Next Sht

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=484619

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Set column widths to match specified sheet

Leith, Thanks for the code.
Dominic, thanks for the add in, quite excellent.

I really appreciate both.

Sean


"Leith Ross" wrote
in message ...

Hello Sean,

Dominic kindly offered you his Add-in in reponse to one part of your
request. I am offering the you the code portion in response to the
second half of your request.

This macro will ask you if you want to apply the active sheet's column
widths to the other sheets in the workbook. If the answer is No, it
does nothing. Insert a VBA module into your project and copy this code
into. You can run the macro from the Macro List (use ALT + F8 to bring
up the list).


Code:
--------------------
Public Sub SetColumnWidths()

Dim Answer, Col, Sht
Dim MasterRng As Range
Dim MasterSht As String
Dim Msg As String

Msg = "Do you want to apply this Worksheet's" & vbCrLf _
& "Column Widths to all the Worksheets?"
Answer = MsgBox(Msg, vbInformation + vbYesNo)
If Answer = vbNo Then Exit Sub

MasterSht = ActiveSheet.Name
Set MasterRng = ActiveSheet.Range("A1", "IV1")

For Each Sht In Worksheets
If Sht.Name < MasterSht Then
For Each Col In MasterRng
Sht.Range(Col.Address).ColumnWidth = Col.ColumnWidth
Next Col
End If
Next Sht

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=484619



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
match first and last name and insert column into existing sheet Sarah Excel Worksheet Functions 1 November 16th 09 04:14 PM
MATCH A NUMBER IN A COLUMN WITH A COLUMN IN A DIFFERENT SHEET L Curly Excel Discussion (Misc queries) 1 July 7th 09 08:04 PM
Can a column have different widths on the same sheet? Patrick Setting up and Configuration of Excel 1 October 27th 06 01:06 AM
Copying a column to a new sheet so that cells match. Nadeem Excel Worksheet Functions 0 October 11th 05 02:03 PM
copy a sheet with all formats - column widths, etc? Rich Excel Programming 2 April 26th 05 09:10 PM


All times are GMT +1. The time now is 11:09 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"