ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Column Width (https://www.excelbanter.com/excel-programming/369357-column-width.html)

grahammal[_35_]

Column Width
 

1) The below macro generates spreadsheets as and when required and works
OK.
The column width of the spreadsheets is 12.75 which is the default
setting.
How can I set the column width to 0.75 from within the macro?

2) How do you set a variable that will be global, I need it to be
recognised in all macros within the same workbook?

Dim ws As Worksheet
Set ws =
ActiveWorkbook.Sheets.Add(after:=ActiveWorkbook.Sh eets(ActiveWorkbook._
Sheets.Count))
ws.Name = "Spreadsheet Name"


--
grahammal
------------------------------------------------------------------------
grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=568241


xcelion

Column Width
 

Hi Graham,

Use ws.Columns.ColumnWidth =0.75

To use a variable as global declare it in the general section of a
module


--
xcelion


------------------------------------------------------------------------
xcelion's Profile: http://www.excelforum.com/member.php...o&userid=16287
View this thread: http://www.excelforum.com/showthread...hreadid=568241


Joerg

Column Width
 

"grahammal" wrote
in message ...
How can I set the column width to 0.75 from within the macro?


The macro recorder is your friend. You can easily find the answer to above
and similar questions yourself when you analyze the code produced by the
macro recorder

2) How do you set a variable that will be global, I need it to be
recognised in all macros within the same workbook?


If all your macros are in one module: DIM MyVariable at the beginning of the
module (in the 'General' section, i.e. outside of any SUB procedure)

If your macros are spread among different modules: PUBLIC MyVariable at the
beginning of any module.

Cheers,
Joerg




All times are GMT +1. The time now is 06:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com