View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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