Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to set column widths in a worksheet

Hi,
I've tried to create a macro that will go in and set the column widths
(columns A thru M) to specific widths. Each column is a different
width. I used the record button and set them as I wanted and then
stopped the recording. When I went to another worksheet in the same
workbook and executed I could see it change the width for a split
second and then they each went to a standard 7.71 width. No error
messages. No explanations.

My goal is a macro to be able to import or copy a page from 5
different worksheets that I receive twice a month and be able to view,
print and extract data from them for other reports.

Thanks in advance,
Phil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Macro to set column widths in a worksheet

Without seeing the code, it is impossible to determine what happened.
However, column width is a function of format and many things affect the
format of cells, columns and rows such as copying from one sheet to another
or from one workbook to another. If you are running SQL, it could have code
that affects format, although rarely so. Your sheet could have had an event
code in it that reset the column width. As I said, there are many things
that could happen after the column width and/or row height is set that might
cause them to change to default or other preset sizes. If you want the best
assistance, post the relevant code so everone can see it.



"Phil Bracken" wrote in message
...
Hi,
I've tried to create a macro that will go in and set the column widths
(columns A thru M) to specific widths. Each column is a different
width. I used the record button and set them as I wanted and then
stopped the recording. When I went to another worksheet in the same
workbook and executed I could see it change the width for a split
second and then they each went to a standard 7.71 width. No error
messages. No explanations.

My goal is a macro to be able to import or copy a page from 5
different worksheets that I receive twice a month and be able to view,
print and extract data from them for other reports.

Thanks in advance,
Phil



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Macro to set column widths in a worksheet

P.S. You might consider running your column width macro after you have
imported data from other workbooks. That would prevent the import process
from changing the format.


"Phil Bracken" wrote in message
...
Hi,
I've tried to create a macro that will go in and set the column widths
(columns A thru M) to specific widths. Each column is a different
width. I used the record button and set them as I wanted and then
stopped the recording. When I went to another worksheet in the same
workbook and executed I could see it change the width for a split
second and then they each went to a standard 7.71 width. No error
messages. No explanations.

My goal is a macro to be able to import or copy a page from 5
different worksheets that I receive twice a month and be able to view,
print and extract data from them for other reports.

Thanks in advance,
Phil



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Macro to set column widths in a worksheet

On Tue, 14 Jul 2009 16:32:55 -0400, Phil Bracken wrote:

Hi,
I've tried to create a macro that will go in and set the column widths
(columns A thru M) to specific widths. Each column is a different
width. I used the record button and set them as I wanted and then
stopped the recording. When I went to another worksheet in the same
workbook and executed I could see it change the width for a split
second and then they each went to a standard 7.71 width. No error
messages. No explanations.

My goal is a macro to be able to import or copy a page from 5
different worksheets that I receive twice a month and be able to view,
print and extract data from them for other reports.

Thanks in advance,
Phil


Sounds strange. Not just that they went back to standard width, but the
standard width you mention is not "Standard". Standard column width in XL,
for as long as I can remember (late 80's) is 8.43 points.

I would redo the macro, and this time, set the column widths for all
sheets, not just the first. See if that helps.

Which still doesn't address the issue of why they went back. ?? Maybe
someone else has run across this glitch.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to set column widths in a worksheet

I've checked and must have deleted the file I was trying to work from.
it was a workbook that had been previously set up by someone else. It
was designed to be printed and then filled in by personnel monitoring
some helium purification equipment. There were merged cells but no
formulas or data entered on it yet.

This was basically practice so that I could perhaps set up a macro to
go in and set column widths in worksheets that I receive twice a month
from our blimp operations. The guys in the field have "tweaked" their
worksheets for their printers, added client logos at the top of the
form and other minor changes. What I want to be able to do is collect
these worksheets in a folder or a master workbook and then be able to
pull data from each one into a summary.

I realize I can pull data from worksheets without worrying about the
column widths but when they are printed and you thumb through them, it
looks terrible. I guess I was just going to tidy it up a bit.

I created a new workbook, increased the number of worksheets for what
I needed and recreated the macro. it worked flawlessly! Which now
brings to mind, how can I be sure that a macro will run on worksheets
from 5 different operators? They were originally all created from one
master workbook but over the years have been passed from one mechanic
to another. They have not been altered radiucally, at least to the
eye, but if that relatively simple macro wouoldn't run on a "empty"
worksheet, what will it do with one that has data in the cells?

Thanks again!

Phil


On Tue, 14 Jul 2009 16:58:54 -0400, "JLGWhiz"
wrote:

Without seeing the code, it is impossible to determine what happened.
However, column width is a function of format and many things affect the
format of cells, columns and rows such as copying from one sheet to another
or from one workbook to another. If you are running SQL, it could have code
that affects format, although rarely so. Your sheet could have had an event
code in it that reset the column width. As I said, there are many things
that could happen after the column width and/or row height is set that might
cause them to change to default or other preset sizes. If you want the best
assistance, post the relevant code so everone can see it.



"Phil Bracken" wrote in message
.. .
Hi,
I've tried to create a macro that will go in and set the column widths
(columns A thru M) to specific widths. Each column is a different
width. I used the record button and set them as I wanted and then
stopped the recording. When I went to another worksheet in the same
workbook and executed I could see it change the width for a split
second and then they each went to a standard 7.71 width. No error
messages. No explanations.

My goal is a macro to be able to import or copy a page from 5
different worksheets that I receive twice a month and be able to view,
print and extract data from them for other reports.

Thanks in advance,
Phil


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
Worksheet Column Widths Different For Different Users Falcon Feet[_2_] Excel Discussion (Misc queries) 2 March 24th 10 01:05 PM
Different column widths within one worksheet saramac24 Excel Discussion (Misc queries) 4 February 8th 07 02:54 AM
Set different column widths on two halves of an Exc worksheet Ballooner Excel Discussion (Misc queries) 1 March 20th 06 08:07 PM
Are different column widths possible on the same worksheet? yinone Excel Worksheet Functions 6 November 18th 05 04:28 PM
Can I have different column widths in a worksheet? Kylie Excel Worksheet Functions 0 July 7th 05 05:03 PM


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

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"