|
-
Apr 30th, 2005, 02:21 AM
#1
Thread Starter
New Member
copy properties in Excel
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?
Last edited by vgray; May 1st, 2005 at 03:13 AM.
-
Apr 30th, 2005, 11:16 AM
#2
Re: copy properties in Excel
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 30th, 2005, 01:03 PM
#3
Thread Starter
New Member
Re: copy properties in Excel
 Originally Posted by RobDog888
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!
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 ?
-
Apr 30th, 2005, 01:06 PM
#4
Re: copy properties in Excel
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 30th, 2005, 10:58 PM
#5
Thread Starter
New Member
Re: copy properties in Excel
 Originally Posted by RobDog888
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 like
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
-
Apr 30th, 2005, 11:13 PM
#6
Re: copy properties in Excel
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.
-
May 1st, 2005, 03:14 AM
#7
Thread Starter
New Member
Re: copy properties in Excel
thank you guys for help, I've solve my problem
-
May 1st, 2005, 10:46 AM
#8
Re: copy properties in Excel
 Originally Posted by RobDog888
...Record your cell formatting and you will get code using something like Cells(1, 1).Font.Interior.ColorIndex and such.
dglienna, already suggested in previous post.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 2nd, 2005, 10:35 PM
#9
Frenzied Member
Re: copy properties in Excel
VB Code:
Cells(6, 3).Copy Cells(6, 4)
Just use something like that, that copies C6 to D6 with all the formatting.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|