Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Fix column widths in Excel template

Excel 2002, Win XP, SP-2

I'm trying to create a pre-formatted template that uses a macro to import
data from a tab delimited file. I would like to fix the column widths so
they do not change during data import. Now, when the data imports, the
column widths automatically adjust themselves to fit the data.



How can I create a template and fix the column widths so they do not change
during data import?. I know I can add the column widths to the macro it
self, but since I create many templates, this is tedious.

--
John Garate



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Fix column widths in Excel template

Dim varr(1 to 10)
for i = 1 to 10
varr(i) = activesheet.columns(i).Columnwidth
Next

' code to import text file


for i = 1 to 10
activesheet.columns(i).Columnwidth = varr(i)
Next


That shouldn't be too tedious.

another approach would be to add a (dummy) sheet, import into that sheet,
then do and edit copy and go to the target sheet and do an edit
pastespecial, values, then delete the dummy sheet

--
Regards,
Tom Ogilvy

"John Garate" wrote in message
...
Excel 2002, Win XP, SP-2

I'm trying to create a pre-formatted template that uses a macro to import
data from a tab delimited file. I would like to fix the column widths so
they do not change during data import. Now, when the data imports, the
column widths automatically adjust themselves to fit the data.



How can I create a template and fix the column widths so they do not

change
during data import?. I know I can add the column widths to the macro it
self, but since I create many templates, this is tedious.

--
John Garate





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
Excel Column Widths When Printing Joe G Excel Worksheet Functions 1 November 24th 09 05:06 AM
Excel 2007 B2TR - Can't keep Column Widths B Smith Excel Discussion (Misc queries) 2 November 27th 06 05:39 AM
Excel 2003 - column widths Hello_It''s_Me-CA New Users to Excel 4 October 20th 06 01:25 AM
Changing column widths in excel Becky Robinson Paine Excel Discussion (Misc queries) 2 June 18th 06 12:55 PM
Excel column widths Rachael Excel Discussion (Misc queries) 6 October 19th 05 09:08 PM


All times are GMT +1. The time now is 11:18 PM.

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"