Results 1 to 6 of 6

Macro copy and paste not pasting exactly whats in cell

Threaded View

  1. #1
    Registered User
    Join Date
    08-08-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    10

    Macro copy and paste not pasting exactly whats in cell

    Hi, the code below looks at column A for the active sheet and then copy and pastes rows based on column A to other sheets.

    sub distribute()
    
    Dim i As Long
    On Error Resume Next
    For i = 2 To Range("A" & Rows.Count).End(3).Row
        Rows(i).Copy
        Sheets(Range("A" & i).Value).Range("A" & Rows.Count).End(3)(2).PasteSpecial xlPasteAll
    Next i
    On Error GoTo 0
    
    
    End Sub
    problem: when I run it,I am getting a bunch of "#ref"'s because the code is not copy and pasting exactly what is on the master sheet.. I cannot post the excel sheet because it has sensitive information on it but here is an example.
    On the master sheet, in cell AB8 is: "=1694200*ReferenceSheet!J4 ". When i run the code it will copy it to the correct sheet in cell AB5 but with "=1694200*ReferenceSheet!J1 " , therefor the result: #ref . My code is not changing anything on the 'reference sheet' and I can manually change "J1" to "j4" and it works fine, but there is too much data to change manually. How can I make the data copy and paste correctly?


    On another issue I have the following:

        With Sheets("ABM")
        LR = .Range("AJ" & Rows.Count).End(xlUp).Row
        .Range("AJ" & LR + 1).Value = FormatCurrency(WorksheetFunction.Sum(.Range("AJ3:AJ" & LR)))
        .Range("AJ" & LR + 1).NumberFormat = "$#,##0_);[Red]($#,##0.)"
        .Range("AJ" & LR + 1).Font.Size = 16
        .Range("AJ" & LR + 1).Font.Bold = True
        .Range("AJ" & LR + 1).Interior.ColorIndex = 15
        End With
        
        With Sheets("Adjudications")
        LR = .Range("AJ" & Rows.Count).End(xlUp).Row
        .Range("AJ" & LR + 1).Value = FormatCurrency(WorksheetFunction.Sum(.Range("AJ3:AJ" & LR)))
        .Range("AJ" & LR + 1).NumberFormat = "$#,##0_);[Red]($#,##0.)"
        .Range("AJ" & LR + 1).Font.Size = 16
        .Range("AJ" & LR + 1).Font.Bold = True
        .Range("AJ" & LR + 1).Interior.ColorIndex = 15
        End With
    BUT, there are 15 sheets, and I need to do it for around 20 columns. What I am doing now is copy and pasting exactly what I posted above and changing the sheet names to the 15 sheets and then changing the columns one at a time. The result is 300 "with sheets(sheet)...(code).....End With. The procedure is too long to run. Is there a way to condense this? There are 15 sheets and the columns that i need to refer to are Z-AN.

    Thanks in advance!! :D
    Last edited by hey1234; 08-22-2014 at 02:28 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA code to save current worksheet as temporary PDF file and then add to my existing code
    By brianfromla in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-20-2014, 08:35 AM
  2. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  3. Replies: 2
    Last Post: 03-09-2013, 04:30 AM
  4. Replies: 2
    Last Post: 03-17-2011, 08:55 PM
  5. Replies: 0
    Last Post: 10-06-2006, 09:05 AM

Tags for this Thread

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