i want to get the cell sizes of every column in one sheet and apply these values to the corresponding columns in a new sheet.
How do i adjust the cell size in excel using Visual basic?
If the second sheet is blank you can create your own macro (I use z for Shortcut) by starting by dragging the mouse across all of the column heading letters (in gray area) then click copy. Now go to the second sheet and do a paste-special -ALL and it will set these col widths like sheet one. If you pasted data into sheet 2 then you can include the steps to highlight the entire area where you need the cells to be blank then click Delete. You can now stop the macro recording.
You can now test it by doing a CTRL-z.
Below is the VB code I used to set 5 column widths and I did not add the delete data lines.
Columns("A:E").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=False
Range("A1").Select
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment