Determining cell format

rpm

New Member
Joined
Aug 28, 2002
Messages
11
I'm writing a macro that works its way down a column and stores the first non-blank cell, populates all blank cells with that value until it finds the next non-blank cell. It takes that value and poulates all blanks. The macro will continue to do this until it hits the bottom of the data. My problem is that if the non-blank value is alpha-numeric (e.g. "00123"), all non-blank cells are populated with a numeric value of 123. I want to retain the leading zeros. There are times when the non-blank value will be a numeric value or a date. In all cases I want to retain the format of non-blank cell.

Any suggestions?

Thanks,
Peter
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi there Peter,

Maybe you can select the entire range where the blank cells would be, hit F5 | Special... | Blanks. Then type = and hit your up arrow (two keyboard storkes), then confirm with Ctrl + Enter at the same time (Ctrl first {holding} then Enter, two more strokes). To leave the values, select the entire range again, press Ctrl + C, then Alt +E, S, V, Esc (seven keyboard strokes). If you want this in code, do this while recording a macro (Tools | Macro | Record New Macro).

If you need more help, post back.
 
Upvote 0
Peter

I would follow firefytr's instructions, but you might also want to format the whole column as Text.

Hopefully that will retain the leading zeroes.
 
Upvote 0

Forum statistics

Threads
1,202,993
Messages
6,052,970
Members
444,623
Latest member
elbertzeeroone

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