Copy format from another cell via macro

roscoe

Well-known Member
Joined
Jun 4, 2002
Messages
1,046
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a macro that I use to simplify data input. The key line is:

ActiveCell.Value = ActiveCell.Offset(-1, 0).Value

The cell it is copying from will be in a certain format. The copy line above only copies the value. How can I drag the formatting attributes with it?

I tried:

ActiveCell.Format = ActiveCell.Offset(-1, 0).Format but that apparently doesn't exist...Excel VBA help only works if you guess close, and that apparently aint it.

Ideas?

Thanks!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about this? It might not be the best way, but it seems to work.

<font face=Courier New>ActiveCell.Copy
ActiveCell.Offset(-1, 0).PasteSpecial Paste:=xlFormats</FONT>
 
Upvote 0
Thanks...I'll try that. Right now I just hard coded the number format I am using into the cell, but I would rather be less rigid if I can help it.
 
Upvote 0

Forum statistics

Threads
1,215,346
Messages
6,124,417
Members
449,157
Latest member
mytux

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top