ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how do i set column widths (https://www.excelbanter.com/excel-programming/357713-how-do-i-set-column-widths.html)

lpdarspe

how do i set column widths
 
I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column B
16.00 or 117 pixels, etc.

Bob Phillips[_6_]

how do i set column widths
 
Take a look at the ColumnWidth property.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"lpdarspe" wrote in message
...
I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column

B
16.00 or 117 pixels, etc.




lpdarspe

how do i set column widths
 
I looked it up in help and it did not help me. How do I write a macro that
will set the column widths as I described?

"Bob Phillips" wrote:

Take a look at the ColumnWidth property.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"lpdarspe" wrote in message
...
I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column

B
16.00 or 117 pixels, etc.





Bob Phillips[_6_]

how do i set column widths
 
Help says it as far as I can see

columns(1).columnwidth = 8.43

as an example

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"lpdarspe" wrote in message
...
I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column

B
16.00 or 117 pixels, etc.




Dave Peterson

how do i set column widths
 
Record a macro when you set each columnwidth to what you want.

lpdarspe wrote:

I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column B
16.00 or 117 pixels, etc.


--

Dave Peterson

lpdarspe

how do i set column widths
 
I tried that but it did not work either. It did not record anything.

"Dave Peterson" wrote:

Record a macro when you set each columnwidth to what you want.

lpdarspe wrote:

I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column B
16.00 or 117 pixels, etc.


--

Dave Peterson


Dave Peterson

how do i set column widths
 
I got this when I recorded a macro:

Option Explicit
Sub Macro1()
Columns("G:G").ColumnWidth = 11.29
Columns("D:D").ColumnWidth = 10.86
End Sub

Maybe you can use it. (I'd try recording a macro once more. I'm guessing that
you did something wrong the first time.)



lpdarspe wrote:

I tried that but it did not work either. It did not record anything.

"Dave Peterson" wrote:

Record a macro when you set each columnwidth to what you want.

lpdarspe wrote:

I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column B
16.00 or 117 pixels, etc.


--

Dave Peterson


--

Dave Peterson

lpdarspe

how do i set column widths
 
Thanks! I made it work using what you copied.

"Dave Peterson" wrote:

I got this when I recorded a macro:

Option Explicit
Sub Macro1()
Columns("G:G").ColumnWidth = 11.29
Columns("D:D").ColumnWidth = 10.86
End Sub

Maybe you can use it. (I'd try recording a macro once more. I'm guessing that
you did something wrong the first time.)



lpdarspe wrote:

I tried that but it did not work either. It did not record anything.

"Dave Peterson" wrote:

Record a macro when you set each columnwidth to what you want.

lpdarspe wrote:

I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column B
16.00 or 117 pixels, etc.

--

Dave Peterson


--

Dave Peterson


[email protected]

how do i set column widths
 
Pardon me for 'piggybacking' on your thread lpdarspe; but how do I make it
stay once it formatted? Protecting the sheet isn't working as they remove
it. Can I just tell it Sub stance()
Range("A:A").ColumnWidth = 2
Range("B:B").ColumnWidth = 7
End Sub

and so forth, will it automatically open and stay at this size? or is there
something else I need to do to make this happen?


"Dave Peterson" wrote:

I got this when I recorded a macro:

Option Explicit
Sub Macro1()
Columns("G:G").ColumnWidth = 11.29
Columns("D:D").ColumnWidth = 10.86
End Sub

Maybe you can use it. (I'd try recording a macro once more. I'm guessing that
you did something wrong the first time.)



lpdarspe wrote:

I tried that but it did not work either. It did not record anything.

"Dave Peterson" wrote:

Record a macro when you set each columnwidth to what you want.

lpdarspe wrote:

I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column B
16.00 or 117 pixels, etc.

--

Dave Peterson


--

Dave Peterson


Dave Peterson

how do i set column widths
 
Those columnwidths should stay that way until you (or the user) does something
to change them.

If you really want to stop anyone from changing the width, you could protect the
sheet (tools|Protection|protect sheet (in xl2003)).

But there are lots of things that won't work when you protect the sheet.

wrote:

Pardon me for 'piggybacking' on your thread lpdarspe; but how do I make it
stay once it formatted? Protecting the sheet isn't working as they remove
it. Can I just tell it Sub stance()
Range("A:A").ColumnWidth = 2
Range("B:B").ColumnWidth = 7
End Sub

and so forth, will it automatically open and stay at this size? or is there
something else I need to do to make this happen?

"Dave Peterson" wrote:

I got this when I recorded a macro:

Option Explicit
Sub Macro1()
Columns("G:G").ColumnWidth = 11.29
Columns("D:D").ColumnWidth = 10.86
End Sub

Maybe you can use it. (I'd try recording a macro once more. I'm guessing that
you did something wrong the first time.)



lpdarspe wrote:

I tried that but it did not work either. It did not record anything.

"Dave Peterson" wrote:

Record a macro when you set each columnwidth to what you want.

lpdarspe wrote:

I want to set the column widths to various sizes. I have columns A thru P
with headers and I want to make a macro that sets the column width of each
column to a certain size. For example column A 5.29 or 42 pixels, column B
16.00 or 117 pixels, etc.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 10:40 AM.

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