LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sizing columns and rows in a workbook

i used the first worksheet in this code because the name may change with your
download. if it's not the first sheet, change the 1 to another number or if the
sheet name is always the same, use that instead.

Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Dim lastcol As Long
Set ws = Worksheets(1)
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column

With ws.Range(ws.Cells(1, "A").Address & ":" & ws.Cells(lastrow, _
lastcol).Address)
.Columns.AutoFit
.Rows.AutoFit
End With

End Sub


--


Gary


"CAM" wrote in message
...
Hello,

I have a workbook that has one worksheet. It's a download and I am always
trying to size the column and rows. I want to have a way I can use VBA
coding to size the columns and rows based on the size of the columns and rows
in a consistent manner. Can anyone help! Thank you advance.

Cheers



 
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
Copy sheet to different workbook sizing error message Jvwulffen Excel Discussion (Misc queries) 2 November 20th 09 09:36 PM
Does sharing a workbook cause columns/rows to unhide? Purrplegrrl77 Excel Discussion (Misc queries) 1 October 21st 09 02:04 PM
Draging formulas and sizing rows/cells Slyons Excel Worksheet Functions 1 March 11th 08 02:48 AM
Sizing of copied columns Nigel[_26_] Excel Programming 0 October 10th 05 06:05 PM
sizing columns in code JulieD Excel Programming 2 July 29th 04 04:29 PM


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