Date Format Change in VBA

hywt1

New Member
Joined
Apr 9, 2019
Messages
5
Hello all, I've created some VBA that does the following:
  • creates new sheet in existing workbook
  • opens file containing SAP derived order book
  • copies data and pastes into previously created new sheet

When this happens the date format is changed for about 25% of lines from date to general. There's nothing in the code to ask for this.

Any ideas why?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Welcome to the Board!

Can you post the VBA code? Especially the part that opens the data?

Note, since you already have VBA code, can't you just add a line or two of code that formats the column the way you want after import?
Or is the issue really more than Formatting, and a Data Type thing (it would be helpful if you could post a few values that are showing up properly, and a few that are not, so we can see what they look like)?
 
Upvote 0
It is probably in the SAP derived source where you have the General formatting coming from.
 
Upvote 0
Sorry, for some reason it seems I can't past into this forum. Even typing at normal speed is next to impossible.


Spiller - the excel file containing the data has everything in the correct date format. The change is noticeable after pasting in to the new sheet.
 
Upvote 0
Even typing at normal speed is next to impossible.
Are you posting from a phone or something? It shouldn't be an issue (I have never had an issue).
I would be interested to hear what kind of device and browser you are trying to post from.

If you wish to paste images to this forum, you would need to use some of the tools mentioned in Section B of this link here: http://www.mrexcel.com/forum/board-a...forum-use.html.
There is a Test Here forum on this board that you can use to test out these tools to make sure they are working correctly before using them in your question.

Or you couold just type in a few examples of that the entries look like.

the excel file containing the data has everything in the correct date format. The change is noticeable after pasting in to the new sheet.
Then it may be how you are pasting it.
 
Upvote 0
Hello Joe

DestoprunnigWindow 7 / IE11

Ta was typed at normal speed an as meant to read Desktop running Windows 7
 
Upvote 0
Hello Joe

DestoprunnigWindow 7 / IE11

Ta was typed at normal speed an as meant to read Desktop running Windows 7
Personally, I find that I get the best performance using Google Chrome, but IE should work fine too.
If you are having issues, I would probably start looking at computer configuration or internet connection/network issues.
Many compamies put virus protection/firewalls that can affect performance.
A good test would be to see if you experience similar issues with other similar forums on the internet.
 
Upvote 0
' GetTodaysFilename Macro
'

'
Dim TodaysFilename As String

Sheets("Workspace").Select
Range("B12").Select
Selection.ClearContents
Range("B10").Select
Selection.Copy
Range("B12").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

TodaysFilename = Range("B12").Value

Workbooks.Open Filename:=TodaysFilename


' Copy New Order Book Data And Close File

'
Selection.CurrentRegion.Select
Selection.Copy
Application.DisplayAlerts = False
ActiveWindow.Close
Application.DisplayAlerts = True


'

Windows("Open Order Data.xlsm").Activate
Sheets("CURRENT").Select
Range("A1").Select
ActiveSheet.Paste
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlToRight
Columns("F:F").Select
Selection.Insert Shift:=xlToRight
 
Upvote 0
Can you post a couple of examples of what these values look like (some of both kinds?).
 
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