+ Reply to Thread
Results 1 to 7 of 7

VBA Help. Transfer sum to another sheet (LOG)

  1. #1
    Registered User
    Join Date
    06-27-2021
    Location
    usa
    MS-Off Ver
    Microsoft 365
    Posts
    4

    VBA Help. Transfer sum to another sheet (LOG)

    Please help, I am creating an invoice and log program for work, so farm my VBA works to do what I need it to do, except it is not pulling the sum of the invoice over into the log.

    The cells on my Sheet1 (FC-80) contain sum formulas and they are throwing a REF#! error--I would like to pull the totals over into the log for each invoice created.

    Please see my attachments for my current coding.
    Attached Images Attached Images

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: VBA Help. Transfer sum to another sheet (LOG)

    a workbook is worth a thousand pictures and a lot easier to manipulate
    see big yellow banner - how to upload your workbook.
    torachan.

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA Help. Transfer sum to another sheet (LOG)

    Hi and welcome

    It would be easier to help if you could attach a desensitized version of your workbook so we can see the issue in context.

    BSB

  4. #4
    Registered User
    Join Date
    06-27-2021
    Location
    usa
    MS-Off Ver
    Microsoft 365
    Posts
    4

    Re: VBA Help. Transfer sum to another sheet (LOG)



    Unfortunately I cannot do that. I am working out of a work account of Excel.

    I guess I will have to scrap this project, I haven't been able to figure it out. I am certain it should be a pastespecial xlpastevalues but I can't get that to work.

    Best I can do is paste the VBA. My Excel is 365 and belongs to the department--not savvy enough to know if its safe to share

    'Create and set variables for each cell in the FC80 sheet
    Dim VENDORNAME As Range, ORDERDATE As Range, PREPARER As Range, SUBTOTAL As Range
    Dim total As Range, SVCLOC As Range, LOGNO As Range

    Set CAMPDOC = FC80.Range("A20")
    Set VENDORNAME = FC80.Range("C12")
    Set ORDERDATE = FC80.Range("G13")
    Set PREPARER = FC80.Range("C9")
    Set SUBTOTAL = FC80.Range("J34")
    Set total = FC80.Range("J36")
    Set SVCLOC = FC80.Range("D42")


    'Create a variable for the paste cell in the FC80 Log worksheet
    Dim DestCell As Range

    If FC80LOG.Range("A2") = "" Then 'If A2 is empty
    Set DestCell = FC80LOG.Range("A2") '...then destination cell is A2
    Else
    Set DestCell = FC80LOG.Range("A1").End(xlDown).Offset(1, 0) '...otherwise the next empty row
    End If

    'If no "VENDOR called has been entered, exit macro
    If VENDORNAME = "" Then
    MsgBox "You must enter a VENDOR NAME before adding to the log"
    Exit Sub
    End If



    'Copy and paste data from the FC80 worksheet to the FC80 Log worksheet

    CAMPDOC.Copy DestCell
    VENDORNAME.Copy DestCell.Offset(0, 1)
    ORDERDATE.Copy DestCell.Offset(0, 2)
    PREPARER.Copy DestCell.Offset(0, 3)
    SUBTOTAL.Copy DestCell.Offset(0, 4)
    total.Copy DestCell.Offset(0, 5)
    SVCLOC.Copy DestCell.Offset(0, 6)


    End Sub
    Last edited by Vallecito; 06-28-2021 at 05:48 PM.

  5. #5
    Registered User
    Join Date
    06-27-2021
    Location
    usa
    MS-Off Ver
    Microsoft 365
    Posts
    4

    Post Re: VBA Help. Transfer sum to another sheet (LOG)



    I got the ok to make a clear copy.
    Attached Files Attached Files

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: VBA Help. Transfer sum to another sheet (LOG)

    Try the attached - learn to use tables - they save a lot of programming and are a more structured approach to data storage.
    Do not manually expand the table - this takes place dynamically on adding or deleting data - the table should not extend with empty rows below the last row of data.
    The data transfer does take place in this instance - but read up on the reasons you should not use merged cell in sheets that have data manipulation taking place.
    In more complex apps things get very messy when data is trying to find its destination reference among a mass of merged cells.
    Have a trial with the attached - any queries post back on this site.
    torachan.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-27-2021
    Location
    usa
    MS-Off Ver
    Microsoft 365
    Posts
    4

    Re: VBA Help. Transfer sum to another sheet (LOG)

    Thank you. That worked. I was pulling my hair out over here.

    I have never done a VBA before. I will have to get better acquainted with VBA, looking for some great resources.

+ 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. [SOLVED] Issue regarding recorded Macro to transfer data from Input sheet to Storage sheet
    By Hirad001 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2015, 04:26 PM
  2. Replies: 5
    Last Post: 12-30-2014, 12:41 PM
  3. Replies: 5
    Last Post: 02-09-2014, 08:29 PM
  4. [SOLVED] Code to transfer latest entry from sheet 'Account' to sheet 'Summary' automatically
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-30-2014, 08:56 PM
  5. How to transfer data from a daily input sheet to a separate monthly total sheet
    By Jcooper71 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2014, 02:37 PM
  6. Replies: 1
    Last Post: 02-13-2013, 01:32 PM
  7. Replies: 0
    Last Post: 09-12-2012, 02:12 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