Copying a 6-digit number with a leading "0"

DJhuffman

New Member
Joined
Apr 16, 2019
Messages
27
The basic premise is that I have four data sets that I want the macro to place into various spots in each file I run it on. For example:
'013125
1/31/25
1/1/25
2/1/25
These items are located in cell B7-B10 of the workbook containing the macros. I used the macro to designate each of these items as "NDA" to "NDD". The last 3 work fine, but the first item continuously drops the leading zero. If possible, I'd like to the target location for NDA to contain the full text of the source, including the apostrophe and the zero.

Here's the code I was using:

VBA Code:
Sub DateUpdate()

CM = ThisWorkbook.Worksheets("Main").Range("B5")
Dim wbkdata As Workbook
NDA = ThisWorkbook.Worksheets("Main").Range("B7")
NDB = ThisWorkbook.Worksheets("Main").Range("B8")
NDC = ThisWorkbook.Worksheets("Main").Range("B9")
NDD = ThisWorkbook.Worksheets("Main").Range("B10")

    Sheets("JE").Activate
    ActiveSheet.Range("C5") = NDA
    Sheets("BS Reserves").Activate
    ActiveSheet.Range("A2") = NDB
    XRow = WorksheetFunction.Match("Change Monthly", Range("A:A"), 0)
    ActiveSheet.Range("A" & XRow + 1) = NDC
    ActiveSheet.Range("A" & XRow + 2) = NDD

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I added your suggestion, but there wasn't any change. I changed B7 on the macro worksheet to text format and the receiving box on the other worksheet to Text as well, and that seemed to work. Thank you for responding.
 
Upvote 0

Forum statistics

Threads
1,226,114
Messages
6,189,051
Members
453,522
Latest member
Seeker2025

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