+ Reply to Thread
Results 1 to 2 of 2

Thread: xlPaste ValuesAndNumberFormats

  1. #1
    Registered User
    Join Date
    10-25-2011
    Location
    Jackson MI
    MS-Off Ver
    Office 2007
    Posts
    8

    xlPaste ValuesAndNumberFormats

    Good Morning, I am hoping Someone can help me here. I am trying to copy 2 named ranges (2 columns) and paste them into 2 different named ranges (again 2 columns) on the same worksheet (code below)

    The VBA works great, with a notable exception. 22 of the 149 rows copy wrong. The formulas in the originating columns are all the same, but when copied, (recreated several times) the ending numbers for those 22 are wrong (same 22 rows, same ending numberson each row, but no number in the column is the same)

    
    ThisWorkbook.Worksheets("eemaster").Range("YrElig").Copy
        Range("PrvElig").PasteSpecial xlPasteValuesAndNumberFormats
    ThisWorkbook.Worksheets("eemaster").Range("YrBank").Copy
         Range("PrvBank").PasteSpecial xlPasteValuesAndNumberFormats
        Application.CutCopyMode = False
    Any help is TRULY appreciated
    Last edited by fhill; 10-25-2011 at 01:42 PM.

  2. #2
    Registered User
    Join Date
    10-25-2011
    Location
    Jackson MI
    MS-Off Ver
    Office 2007
    Posts
    8

    Re: xlPaste ValuesAndNumberFormats

    *BUMP*

    Okay, now that I have sat back and contemplated my evil coding, I realized that since both columns have calculations which rely on each other, I have to actually copy the range into a new range as values, and THEN move them to the correct places, then deleting said temporary ranges.

    ThisWorkbook.Worksheets("eemaster").Range("YrElig").Copy
        Range("EligTemp").PasteSpecial xlPasteValuesAndNumberFormats
    ThisWorkbook.Worksheets("eemaster").Range("YrBank").Copy
         Range("BalTemp").PasteSpecial xlPasteValuesAndNumberFormats
         ThisWorkbook.Worksheets("eemaster").Range("EligTemp").Copy
        Range("PrvElig").PasteSpecial xlPasteValuesAndNumberFormats
    ThisWorkbook.Worksheets("eemaster").Range("BalTemp").Copy
         Range("PrvBank").PasteSpecial xlPasteValuesAndNumberFormats
        Application.CutCopyMode = False
    ThisWorkbook.Worksheets("eemaster").Range("EligTemp", "BalTemp").ClearContents
    This eliminates the "altered" data I was seeing.

    If anyone has a simpler (more elegant) way of doing this I am open to suggestions.

    On a side note, how DO you delete your own post?

+ 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.2.0