Results 1 to 26 of 26

How to convert exported text date to desired date format with excel vba.

Threaded View

sktneer How to convert exported text... 09-25-2013, 06:22 AM
patel45 Re: How to convert exported... 09-25-2013, 06:27 AM
sktneer Re: How to convert exported... 09-25-2013, 06:32 AM
patel45 Re: How to convert exported... 09-25-2013, 06:53 AM
JOHN H. DAVIS Re: How to convert exported... 09-25-2013, 06:43 AM
sktneer Re: How to convert exported... 09-25-2013, 07:09 AM
JOHN H. DAVIS Re: How to convert exported... 09-25-2013, 07:24 AM
sktneer Re: How to convert exported... 09-25-2013, 07:39 AM
AB33 Re: How to convert exported... 09-25-2013, 09:54 AM
sktneer Re: How to convert exported... 10-01-2013, 07:02 AM
Norie Why don't you import the data... 09-25-2013, 09:58 AM
Norie Re: How to convert exported... 10-01-2013, 07:10 AM
sktneer Re: How to convert exported... 10-01-2013, 08:31 AM
Norie Re: How to convert exported... 10-01-2013, 10:28 AM
sktneer Re: How to convert exported... 10-01-2013, 10:44 AM
Norie Why would you run it a 2nd... 10-02-2013, 10:28 AM
sktneer Re: How to convert exported... 10-02-2013, 10:36 AM
Norie Why are you using the... 10-02-2013, 10:49 AM
sktneer Re: How to convert exported... 10-02-2013, 02:08 PM
Norie Re: How to convert exported... 10-02-2013, 02:13 PM
sktneer Re: How to convert exported... 10-02-2013, 02:49 PM
Norie Re: How to convert exported... 10-02-2013, 02:53 PM
sktneer Re: How to convert exported... 10-03-2013, 01:08 AM
  1. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: How to convert exported text date to desired date format with excel vba.

    Quote Originally Posted by Norie View Post
    This will do the conversion without any helper columns.
    Dim rng As Range
    
        Set rng = Range("B2", Range("B" & Rows.Count).End(xlUp))
    
        With rng
            .TextToColumns Destination:=.Cells(1, 1), DataType:=xlDelimited, _
                           TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
                           Semicolon:=False, Comma:=False, Space:=False, Other:=False, _
                           FieldInfo:=Array(1, 5), TrailingMinusNumbers:=True
            .EntireColumn.AutoFit
        End With
    
        With rng.Offset(, 1)
            .TextToColumns Destination:=.Cells(1, 1), DataType:=xlDelimited, _
                           TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
                           Semicolon:=False, Comma:=False, Space:=False, Other:=False, _
                           FieldInfo:=Array(1, 5), TrailingMinusNumbers:=True
            .EntireColumn.AutoFit
        End With
    Thanks Norie for helping me. Would you please explain a bit what will this piece of code do? Because I am not expert of VBA. But I tried to include your code within my code (which is a sub-routine known as pastefromclipboard()) and my code inserts the data at desired location, but when it comes to your code then, it gives an error '1004' (No data was selected to parse.)

    Would you please guide me that how to use this code.

    Please find the sheet attached with my code for pasting the data from clipboard. This code runs well very first time, but when I run it second time the date columns show only ########, which is strange to me.

    You can copy the below data and run the macro pastefromclipboard() to see what it does.


    SBO507175300,20130705,20130920,62
    SBO864070985,20130705,20130919,62
    SBO177492601,20130705,20130927,77
    SBO710237444,20130705,20130920,62
    SBO962342877,20130705,20130930,59
    SBO19704115,20130705,20130918,81
    SBO191859391,20130705,20130927,67
    SBO477581883,20130705,20130929,72
    SBO337574486,20130708,20130929,82
    SBO58479395,20130708,20130924,78
    SBO462419969,20130712,20130912,114
    SBO555497224,20130712,20130929,69
    SBO628084891,20130712,20130924,74
    SBO569899162,20130719,20130923,82
    SBO350825729,20130719,20130926,62
    SBO171753411,20130719,20130927,49
    SBO613615026,20130719,20130930,58
    SBO925727239,20130719,20130925,53
    SBO366112445,20130719,20130922,67
    SBO123327454,20130719,20130924,54
    SBO251091491,20130719,20130927,84
    SBO458342174,20130719,20130927,68
    Regards
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cannot convert date (which is in text format) to date in numeric format
    By geniuspro in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-19-2012, 09:21 AM
  2. Formula to convert text to a date in a date format
    By mikeburg in forum Excel General
    Replies: 5
    Last Post: 08-24-2011, 09:15 AM
  3. convert date format to text in all excel files in a folder
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-31-2011, 01:12 PM
  4. Help: How do I convert a text date into a real date format
    By japorms in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-02-2006, 01:36 PM
  5. Replies: 2
    Last Post: 11-16-2005, 08:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1