how2 keep #stored as text as #stored as text in macro variab

theomountain

New Member
Joined
Jan 22, 2003
Messages
29
How do I keep the format of my variable value in a macro as number stored as text

locn = activecell.value (the active cell shows 0023, number stored as text)
The column is formatted as text
with the macro I go to another sheet (same workbook), select a cell and
activecell.value = locn (this active cell shows 23)
this column is formatted as text

how do I get the value to show 0023?

Is there a VBA command extension that will force the value to stay the same

Thanks
Theo
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try like this

Code:
Sub test()
Sheets("Sheet1").Range("A1").Copy
Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlValues
Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlFormats
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,601
Messages
5,597,117
Members
414,126
Latest member
jellevansoelen

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
Top