![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Before to copy and paste a sheet in another sheet,I want that the columnwidth in the second sheet is 10
How to do this with a code in my macro? Many thanks. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Cape Town,South Africa
Posts: 234
|
Hello Friend
This code will set your width of the columns to 15 characters,hope it helps you. Sub width() Dim Col As Range Set Col = Range(ActiveCell.Offset(0, 1), ActiveCell.End(xlDown).Offset(0, 1)) ActiveCell.Offset(0, 1).Select ActiveCell.FormulaR1C1 = "=IF(LEN(RC[-1])>15,LEFT(RC[-1],15),RC[-1])" Selection.AutoFill Destination:=Col, Type:=xlFillDefault Selection.Copy Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False End Sub have a nice day |
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
This is a piece of my macro: Cells.Clear ColumnsWitdth = 10 ActiveWindow.DisplayHeadings = False kopi.Copy Range("A6").Select ActiveSheet.Paste The line "ColumnsWitdth = 10" doesn't work. Is this not possible with one code in place of your whole macro above? Many thanks. |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
This will set the width of every column on your active sheet to ten... ActiveSheet.Cells.ColumnWidth = 10 Tom |
|
|
|
|
|
#5 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Location: Cape Town,South Africa
Posts: 234
|
Sorry my friend
I did not know you only wanted a string and not a code ? |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|