Excel Date Issue

1Coolhand

New Member
Joined
Jun 2, 2011
Messages
6
Hello all,

I have an issue that I am trying to resolve. I have an excel spreadsheet that we save into .csv format to upload to a 3rd party system. This system requires that the date column is in the format DDMMYYYY. When I get the extract, there are about 7500 columns with the date listed (ex 6/2/2011) The column is formatted as General.

I need to be able to do the following:

1. Convert this column to MMDDYYYY format (06022011) with the leading zero for single digit months and single digit days.

2. I need to subtract 1 day from the result (ex. 06022011 needs to go to 06012011 or for the first day of the month 06012011 needs to go to 05312011)

I am not a large VBA guru so any help would be appreciated.
 
TRY THIS

Code:
Public Sub dATEIT()
Dim c As Range
 
     On Error Resume Next
     For Each c In Selection
 
        c.Value = "'" & Format(c.Value - 1, "mmddyyyy")
 
 
     Next c
 
End Sub

put it in a module

then select the date column

and run

BACK UP FIRST BECAUSE THIS CHANGES THE DATA TO TEXT !!!!
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Can you post the code you have?

Also what do you mean by 'only pasted that special to a certain amount of rows, what happens if the extract contains about 8000 rows'?

Does that not mean the code you have doesn't cater for the changing amount of rows?
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

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