Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy sheet to different workbook sizing error message | Excel Discussion (Misc queries) | |||
Does sharing a workbook cause columns/rows to unhide? | Excel Discussion (Misc queries) | |||
Draging formulas and sizing rows/cells | Excel Worksheet Functions | |||
Sizing of copied columns | Excel Programming | |||
sizing columns in code | Excel Programming |