Hello again,
here's another question from me
I have let say 5 sheets in a workbook and I want to copy columns width from 1 sheet to another 2 sheets, how to do that using macro?? I don't want to use autofit with the code anyway.
Thanx
Hello again,
here's another question from me
I have let say 5 sheets in a workbook and I want to copy columns width from 1 sheet to another 2 sheets, how to do that using macro?? I don't want to use autofit with the code anyway.
Thanx
As an example copy Columns A:E from Sheet1 to Sheet2
![]()
Worksheets("Sheet1").Columns("A:E").Copy Worksheets("Sheet2").Columns("A:E").PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False
Hope this helps.
Anthony
Pack my box with five dozen liquor jugs
PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?
Thank you very much smuzoen, that works![]()
finally I make it like follow, but may be you have a better suggestion:
thanks![]()
Sub AdjustWidth() Dim wsh As Variant Application.ScreenUpdating = False ActiveSheet.Columns("A:J").Copy x = ActiveCell.Address t = ActiveSheet.Name For Each wsh In Array(Sheet3, Sheet4, Sheet5) wsh.Columns("A:J").PasteSpecial Paste:=xlPasteColumnWidths, operation:=xlNone, SkipBlanks:=False, Transpose:=False wsh.Activate ActiveSheet.Range(x).Select Next wsh Sheets(t).Activate Application.CutCopyMode = False Application.ScreenUpdating = True End Sub
The only comment would be is that there is no need to activate or select in the loop above - I cannot see that as being required so you could remove this. Sheets do not have to be active or selected to effect a copy command as long as the correct sheet is referenced which you have done in your code.
well, I just want the selection to be cleared when finish, I don't like the grey area left after the macro is done.
thank you again for your suggestion master smuzoen, you're the man.![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks