Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CAM CAM is offline
external usenet poster
 
Posts: 65
Default Sizing columns and rows in a workbook

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Sizing columns and rows in a workbook

Hi Cam

Here is a start you should be able to change to suit your
requirements. It assumes your datas length is determined by coumn As
row length. It assumes your download goes from Columns A to N. It
also assumes you want the columns autofit. Lot of assumptions.

Good luck

Marcus

Sub ChangeHeight()
Dim lw As Integer

lw = Range("A" & Rows.Count).End(xlUp).Row

For i = lw To 2 Step -1
Range("A" & i).EntireRow.AutoFit
Range("A:N").EntireColumn.AutoFit
Next i

End Sub
  #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



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
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 12:38 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"