+ Reply to Thread
Results 1 to 4 of 4

Pasting a range changes some formats to date

  1. #1
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    Pasting a range changes some formats to date

    Hi, I have a macro that pastes a range into a sheet and then loops column A of the pasted range to strip out the leading characters

    Here is the list of the values in column A and then after the = it shows what ends up on my target sheet
    WSRE326057 = 16/09/2792
    WSRE326294 = 11/05/2793
    WSRE326326 = 12/06/2793
    WSRE326371 = 326371

    I can format the cells after the even to be "General" but it's really bugging me that my macro wont just paste what I have copied.

    here is the little bit of loop code that strips out the leading values

    Please Login or Register  to view this content.
    Hope someone can help

    Thanks
    John

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,366

    Re: Pasting a range changes some formats to date

    It worked OK for me.

    Maybe the cells were formatted before you put the data in them?

    Try:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    Re: Pasting a range changes some formats to date

    Hi, thanks for the reply and sorry for my late response.

    I've found the cause of the problem now. Column A of my original range that I was copying had some cells formatted as date (but I didnt realise as the values looked like text). I have now changed the original copy range to be text format and all works fine now.

    Only thing I was still confused about was the fact that cell.numberformat = "General" would always result in an error. Excel seemed unable to convery from date to General. Anyway I've fixed the cause of the problem so I'm not too concerned about that now.

    Thanks again for your reply

    John

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,366

    Re: Pasting a range changes some formats to date

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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