Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 209
Default wasy macro question

I used the macro recorder to get the code to resize columns on a worksheet

Cells.Select
Range("A1766").Activate
Cells.EntireColumn.AutoFit

What I don't understand in the Range. It's seems to be referring to a
single cell. Could someone explain to a VBA newbie?

I'm importing a text file and I want to resize the columns after import.
I have the import working just need this one last thing.

The worksheet will always have the same number of columns but the number
of rows may vary will the above code still work?

gls858
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 209
Default wasy macro question

gls858 wrote:
I used the macro recorder to get the code to resize columns on a worksheet

Cells.Select
Range("A1766").Activate
Cells.EntireColumn.AutoFit

What I don't understand in the Range. It's seems to be referring to a
single cell. Could someone explain to a VBA newbie?

I'm importing a text file and I want to resize the columns after import.
I have the import working just need this one last thing.

The worksheet will always have the same number of columns but the number
of rows may vary will the above code still work?

gls858


That supposed to be easy macro question

  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10,593
Default wasy macro question

The range is a single cell, but you use entirecolumn later.

I would just use

Columns(1).Autofit

or

Columns("A").Autofit

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"gls858" wrote in message
...
I used the macro recorder to get the code to resize columns on a worksheet

Cells.Select
Range("A1766").Activate
Cells.EntireColumn.AutoFit

What I don't understand in the Range. It's seems to be referring to a
single cell. Could someone explain to a VBA newbie?

I'm importing a text file and I want to resize the columns after import.
I have the import working just need this one last thing.

The worksheet will always have the same number of columns but the number
of rows may vary will the above code still work?

gls858



  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 209
Default wasy macro question

Bob Phillips wrote:
The range is a single cell, but you use entirecolumn later.

I would just use

Columns(1).Autofit

or

Columns("A").Autofit


Thanks Bob. I just posted what the recorder recorded. I'm a newbie when
it comes to VBA. I'll give your suggestion a try.

gls858
  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,345
Default wasy macro question

This is what I get in XL97 when I use the Macro Recorder:

Cells.Select
Selection.Columns.AutoFit

You can of course take out the two Selects and just have:

Cells.Columns.AutoFit

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"gls858" wrote in message
...
I used the macro recorder to get the code to resize columns on a worksheet

Cells.Select
Range("A1766").Activate
Cells.EntireColumn.AutoFit

What I don't understand in the Range. It's seems to be referring to a
single cell. Could someone explain to a VBA newbie?

I'm importing a text file and I want to resize the columns after import.
I have the import working just need this one last thing.

The worksheet will always have the same number of columns but the number
of rows may vary will the above code still work?

gls858





  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10,593
Default wasy macro question

That is the problem with the MR, it records every step. So you select a
cell, then you autofit the column, two steps, so that is what the MR
records. A bit of a pain, but understandable.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"gls858" wrote in message
...
Bob Phillips wrote:
The range is a single cell, but you use entirecolumn later.

I would just use

Columns(1).Autofit

or

Columns("A").Autofit


Thanks Bob. I just posted what the recorder recorded. I'm a newbie when it
comes to VBA. I'll give your suggestion a try.

gls858



  #7   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 209
Default wasy macro question

Sandy Mann wrote:
This is what I get in XL97 when I use the Macro Recorder:

Cells.Select
Selection.Columns.AutoFit

You can of course take out the two Selects and just have:

Cells.Columns.AutoFit


Thanks for the input Sandy.

gls858
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
Macro Question Vick Excel Discussion (Misc queries) 1 November 27th 07 02:58 PM
Macro Question ALoecher New Users to Excel 3 March 9th 06 10:12 PM
Macro Question carl Excel Worksheet Functions 1 August 3rd 05 07:56 PM
Macro Question Chris Excel Worksheet Functions 0 July 18th 05 04:02 PM
Question about macro Jason Excel Discussion (Misc queries) 0 April 27th 05 10:37 PM


All times are GMT +1. The time now is 12:29 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"