Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Column Widths Doug Excel Worksheet Functions 1 October 6th 09 04:56 AM
Different widths for each column in a 100% stacked column chart Chart Explorer Charts and Charting in Excel 1 May 21st 09 09:19 AM
Column Widths Big Rick Excel Discussion (Misc queries) 2 February 20th 06 03:40 PM
Column widths jrpOR Excel Worksheet Functions 2 August 6th 05 01:44 AM
Column Widths help ? GazMo[_11_] Excel Programming 2 October 26th 04 12:55 PM


All times are GMT +1. The time now is 10:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"