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
 

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,)
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
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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