Combine a Date Serial And Number To Create A String

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this line of code in my project...
Code:
.Cells(i, 1) = CStr(CLng(.Cells(i, 2)) & Format(i - 1, "000"))

Its purpose is to create a value for cell A(row) = the combined values of cell B(row) (a true date value formatted as yyyy-mm-dd), and the row number (i) minus 1.

So, if the date value in B2 = 2019-06-24, then what I would like to get for A2 is a value of 43640001 (the date serial combined with the previous row number)

What I am getting instead is 4E+07.

Suggestions for improvement?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
If you increase the column width...

Immediately after the loop (after Next i) insert this line
.Columns(1).AutoFit

Hope this helps

M.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

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