How Do I Format NOW() to string in a Macro?

blackwell7six

New Member
Joined
Jun 15, 2018
Messages
1
Forgive me, I'm new to VBA. I have enough experience in programming, but it's not my bag. I'm currently trying a macro to copy data from one sheet to a table, and that data includes a NOW() function formatted the way I want. When I copy it over to the table, it's just copying the NOW() and I want it as a string. In other words, when I copy it over, it's constantly changeing the date of the other entries to the current date/time. I want to preserve the date and time I made the entry. Here's my code:

Range("B2,B3,B7,B11").Select
Range("B11").Activate
Selection.Copy
Sheets("Database").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Rows("2:2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Intake").Select
Range("B2,B4,B5,B6,B7,B8,B9,B10,B11").Select
Range("B11").Activate
Selection.ClearContents

How can I change this to do what I want it to do?

Thanks in advance.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Welcome to the Board!

The NOW() function returns the current date/time and is always changing.
If you want to copy "freeze" the date/time at the time of copying, use Copy -> Paste Special -> Values, to copy the value and not the formula.

It looks like you got the code above by using the Macro Recorder, so you should be able to use it to record the Copy -> Paste Special -> Values step to get the code that you need.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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