+ Reply to Thread
Results 1 to 5 of 5

When Copy and Paste a subtotal to another worksheet I receive an error #REF!

  1. #1
    Registered User
    Join Date
    10-05-2023
    Location
    Atlanta, Ga.
    MS-Off Ver
    Microsoft 365
    Posts
    3

    When Copy and Paste a subtotal to another worksheet I receive an error #REF!

    Each month I download a workbook containing approximately 20K call detail records. What I am trying to do is sort the call detail records by column "F" ("Transfer Dest") and then subtotal on column "J" (Duration). Duration is how many seconds were used for that telephone number.

    For example, telephone number (Transfer Dest) 2048082561 was used for 3210 seconds (Duration).

    So far, I have been able to use VBA to sort on Column "F" (Transfer Dest) and subtotal on column "J" (Duration) and collapse the outline to provide only the telephone numbers with their summed
    minutes of use column "J" (duration). Once the subtotal has completed, my records that I need to keep track of reduced from approximately 20k to approximately 100 transfer numbers that I need to keep track of.

    Here is my problem that I need help with - When I run my code it will copy the telephone number from worksheet labeled "Raw Data" and pastes that number to worksheet labeled "Import To DB" perfectly. When the code copies the numbers in column "J" (duration) and pastes it to the worksheet labeled "Import To DB" I receive the error #REF! instead of the duration time (seconds). It pastes the formula and not the value into the cell. how can I copy and paste only the values in the duration column?

    If you see the attached workbook you will see on the "Raw Data" sheet what I am copying and, on the worksheet, "Import To DB" you will see the errors shown on the two worksheets named above. Please see the workbook labeled "Transfer Report" for details. I have my code in the workbook for your review.

    Any help or suggestions would be greatly appreciated. Thank you in advance for your time and knowledge in this matter. If there is a better way or more efficient way of completing this task, I am all ears.

    Below I have pasted my code and the error comes from this line: c.Offset(0, 4).Copy Destination:=Worksheets(4).Cells(i, 4)
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by 6StringJazzer; 10-05-2023 at 04:09 PM. Reason: please use code tags

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: When Copy and Paste a subtotal to another worksheet I recieve an error #REF!

    Avoid using numeric indexes for worksheet references. If the user changes the order of the tabs, it breaks the code. The most reliable method is to use CodeName.

    Why do you have a condition that guarantees a result of TRUE?
    Please Login or Register  to view this content.
    Offset(0,0) has no effect
    Please Login or Register  to view this content.
    To copy value only:
    Please Login or Register  to view this content.
    Indentation does not follow code structure

    Code after rewriting and testing:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: When Copy and Paste a subtotal to another worksheet I receive an error #REF!

    Maybe a pivot table
    Attached Files Attached Files
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    10-05-2023
    Location
    Atlanta, Ga.
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: When Copy and Paste a subtotal to another worksheet I recieve an error #REF!

    Jeff,

    I really appreciate your help and the quick response. Thank you very much!

    As you can see i am a beginner at writing VBA. I do appreciate your comments, questions, and suggestions.

    Your code works great!

    Thank You,
    Chris

  5. #5
    Registered User
    Join Date
    10-05-2023
    Location
    Atlanta, Ga.
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: When Copy and Paste a subtotal to another worksheet I receive an error #REF!

    Ben Van Johnson,

    Thank you for your suggestion. your suggestion works great. I really should learn more about pivot tables. it seems i can do a lot with it. i am going to look into this suggestion as well.

    Thanks again for your help and quick response.

    Best Regards,
    Chris J

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel Subtotal Line - Copy paste upper row to subtotal Line
    By ayyappan80 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2020, 05:11 AM
  2. Copy new entry to Another Worksheet that Have Subtotal
    By taccat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2013, 09:01 PM
  3. Copy, Paste into Subtotal Row
    By zinoviia660 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-02-2010, 10:22 AM
  4. Replies: 1
    Last Post: 06-30-2006, 04:15 AM
  5. Re: Subtotal - copy to other worksheet
    By Bill in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2005, 08:05 PM
  6. Subtotal - copy to other worksheet
    By Bill in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2005, 05:05 PM
  7. Replies: 0
    Last Post: 08-08-2005, 06:05 PM

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