Excel makes me crazy :) I need to make identical copy of cell.
I need something like
VB Code:
Worksheets("Sheet1").Cells(1, 1) = Worksheets("Sheet1").Cells(1, 2)
but it copyes only value, but I also need fonts, borderds, etc ..
How can I do it?
Printable View
Excel makes me crazy :) I need to make identical copy of cell.
I need something like
VB Code:
Worksheets("Sheet1").Cells(1, 1) = Worksheets("Sheet1").Cells(1, 2)
but it copyes only value, but I also need fonts, borderds, etc ..
How can I do it?
Welcome to the Forums.
Whenever you need to know how to access most Office VBA properties, you can record a macro doing your task
and then stop it and check the module code in the vba editor to see how the macro does it. ;)
yeah, really good advice!Quote:
Originally Posted by RobDog888
but I think it is not optimal, becouse macro looks like
VB Code:
Range("D18").Select Selection.Copy Range("D12").Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False
Is there another way to do it ?
You didnt record yourself adding the formatting to the cell?
It is only a way to determine what objects/methods/properties are involved. Not necessarily the exact code to use. ;)
Record your cell formatting and you will get code using something like Cells(1, 1).Font.Interior.ColorIndex and such.
aaa, now I understand you, but I thought there is another way than write some thing likeQuote:
Originally Posted by RobDog888
VB Code:
Cells(1, 1).Font.Interior.ColorIndex = Cells(1, 2).Font.Interior.ColorIndex
:( If there is no way, in such case macro will not help me, becouse all properties well described in Excel's help
Very bad that Excel does not allow something like
VB Code:
Cells(1, 1).Font = Cells(1, 2).Font
Record a macro of you formatting the first cell with all of the properties that you will need, and you will then have a macro that will format the second cell.
When you have that, you can use the code to format the cell anytime.
If the formatting is not the same each time, it will be harder, but as long as you allow for each possibility then you will still be able to use code.
thank you guys for help, I've solve my problem :)
dglienna, already suggested in previous post. ;)Quote:
Originally Posted by RobDog888
Just use something like that, that copies C6 to D6 with all the formatting.VB Code:
Cells(6, 3).Copy Cells(6, 4)