VBA to copy data over in date format

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello - I have my data that will present a date in 20200924 format. I am using the below code to transfer the data over. but i need the data after transferred over to be in 9/24/2020 format. Is there a modification I can do to the below to accomplish it or do i need to rewrite that all?
VBA Code:
With Sheets("Compare")
  rws = .Range("H13:H13").End(xlDown).row - 12
  Sheets("D").Range("N2").Resize(rws, 1).Value = .Range("H13").Resize(rws).Value
End With
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Maybe test the below on a copy of your data

VBA Code:
    With Sheets("Compare")
        rws = .Range("H13").End(xlDown).Row - 12
        
        With Sheets("D").Range("N2").Resize(rws)
            .Value = .Range("H13").Resize(rws).Value
            
            .TextToColumns Destination:=Range("N2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
            
            .NumberFormat = "mm/dd/yyyy"
        End With
        
    End With
 
Upvote 0
I
Maybe test the below on a copy of your data

VBA Code:
    With Sheets("Compare")
        rws = .Range("H13").End(xlDown).Row - 12
       
        With Sheets("D").Range("N2").Resize(rws)
            .Value = .Range("H13").Resize(rws).Value
           
            .TextToColumns Destination:=Range("N2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
           
            .NumberFormat = "mm/dd/yyyy"
        End With
       
    End With
I am getting error at the texttcolumn blurb

1601008032938.png
 
Upvote 0
What do you get with

VBA Code:
    With Sheets("Compare")
        rws = .Range("H13").End(xlDown).Row - 12
        
      
            Sheets("D").Range("N2").Resize(rws).Value = .Range("H13").Resize(rws).Value
            
            Sheets("D").Range("N2").Resize(rws).TextToColumns Destination:=Range("N2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
            
            Sheets("D").Range("N2").Resize(rws).NumberFormat = "mm/dd/yyyy"
      
        
    End With
 
Upvote 0
What do you get with

VBA Code:
    With Sheets("Compare")
        rws = .Range("H13").End(xlDown).Row - 12
       
     
            Sheets("D").Range("N2").Resize(rws).Value = .Range("H13").Resize(rws).Value
           
            Sheets("D").Range("N2").Resize(rws).TextToColumns Destination:=Range("N2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
           
            Sheets("D").Range("N2").Resize(rws).NumberFormat = "mm/dd/yyyy"
     
       
    End With
Nice! Works so far :)
 
Upvote 0

Forum statistics

Threads
1,215,727
Messages
6,126,521
Members
449,316
Latest member
sravya

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