+ Reply to Thread
Results 1 to 13 of 13

Adding info from two tabs, to a third one using a macro Excel 2010

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    70

    Adding info from two tabs, to a third one using a macro Excel 2010

    Hi
    I am trying to add data from two tabs, to a third one, using a macro. Can someone tell me how to go about this please?
    I color coordinated things. So everything in the report tab that has a yellow legend comes from the Order summary tab.
    Everything in the report tab that has a red heading comes from the order details tab.
    I also coordinate the columns too.
    Can you help please?
    Thank you.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    I believe this is a start on what you want to achieve but believe it still needs some work. This adds the data to the next line on the Report worksheet. But it only adds the first item of info from the item Details page.

    I think you need to be able to add data for each item of the detail? If so, the code likely needs to be modified further to add all of the detail first, then copy down the customer summary info for each line of detail.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-20-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    70

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    Correct, I need to be able to add data for each item of the detail. Also need to paste the info from Order details called "product name" on to column R on the report tab, please and thank you.

  4. #4
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    This will add all 10 items in your detail.

    But will you always have 10 items? What if you have more then 10 items?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-20-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    70

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    Almost there..the only issue that it has is, when you put the cursor on the next available blank row. And press the macro button again, to add something else, it skips a row. Can you make it so it doesnt skip a row, and it add something on the next available blank row?

  6. #6
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    Quote Originally Posted by celeazul View Post
    Almost there..the only issue that it has is, when you put the cursor on the next available blank row. And press the macro button again, to add something else, it skips a row. Can you make it so it doesnt skip a row, and it add something on the next available blank row?
    Not sure what you are seeing. I am not seeing an extra blank or skipped row.

    Your using Excel Table formatting as well. So it adds a row to the end of the table range/rows.

    Do you want it add an extra blank row between each order?

  7. #7
    Registered User
    Join Date
    07-20-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    70

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    Lets say i press the "add to report" button, it adds the info, which is good.
    But lets say you go to the last column on the right. And press enter on your keyboard.
    And go back to the next available row, on column A.
    And you press the "add to report" button again, because you want to add say another order.
    It skips a row. And instead of if it typing and replicating the info on row 16 it starts on row 17.
    I prefer it starts on row 16. So it doesnt skips rows, you know what i mean?

  8. #8
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    Are you using the file I posted? I believe I follow what you are saying, but I do not see that behavior occurring.

    but remember. the code is addding all 10 items from the detail, even it they item is 'blank'. There is no current checks if only 8 items were added, etc.

  9. #9
    Registered User
    Join Date
    07-20-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    70

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    Yes I am using the file you attached. If you open it, you'll see what I mean. If you click on the add to report" button, it adds it correctly.
    But if you click on it again, then it skips a row.
    Its not supposed to skip a row.

  10. #10
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    Swap the old line of code for the new one and you should be okay. The new line is the first line.

    Please Login or Register  to view this content.
    By adding a blank row in the table the .End(xlUp) method sees the blank row as having data.
    .End(xlUp) is the same as holding the control key and pushing the up arrow. If you are many rows below any data doing this will jump you to the next row with data. If you go down several rows below blank rows in a table you will see that it jumps to the last blank row.
    This is due to it being a table.
    Last edited by skywriter; 07-20-2015 at 02:15 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  11. #11
    Registered User
    Join Date
    07-20-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    70

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    You mean it should be this correct?

    Sub AddToReport()
    Dim i As Long, NextRow As Long
    Dim NextAmount As Long, NextDescription As Long

    'Get Next/Last Row
    NextRow = Sheets("Report").Cells(Cells.Rows.Count, "C").End(xlUp).Row

    NextRow = Sheets("Report").Range("C:C").Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious).Row
    'NextRow = Sheets("Report").Cells(Cells.Rows.Count, "C").End(xlUp).Row

    NextAmount = 19
    NextDescription = 21

    For i = 1 To 10
    'Copy Order Details to Report
    'Row Offset to next item

    Sheets("Report").Range("R" & NextRow + i) = Sheets("Order Details").Range("B" & NextAmount) 'Prod Name
    Sheets("Report").Range("Q" & NextRow + i) = Sheets("Order Details").Range("C" & NextAmount) 'Item Num
    Sheets("Report").Range("F" & NextRow + i) = Sheets("Order Details").Range("D" & NextAmount) 'Amount

    Sheets("Report").Range("H" & NextRow + i) = Sheets("Order Details").Range("D" & NextDescription) 'Quantity
    Sheets("Report").Range("S" & NextRow + i) = Sheets("Order Details").Range("B" & NextDescription) 'Item Description

    'Copy Order Summary Data to each line of Detail Added
    Sheets("Report").Range("A" & NextRow + i) = Sheets("Order Summary").Range("C7") 'Consultant
    Sheets("Report").Range("C" & NextRow + i) = Sheets("Order Summary").Range("C17") 'Code
    Sheets("Report").Range("D" & NextRow + i) = Sheets("Order Summary").Range("D17") 'Client

    NextAmount = NextAmount + 8
    NextDescription = NextDescription + 8
    Next i
    End Sub

  12. #12
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    You mean it should be this correct?
    No.

    You left in the old code.

    I just modified the code from the sheet ptmuldoon posted.

    Credit to ptmuldoon for helping you and I would hope you would press the Add Reputation button in the lower left hand corner of one of ptmuldoon's posts.

    This is a behavior that I became aware of the hard way and ptmuldoon may be unaware of it.

    Please Login or Register  to view this content.
    Last edited by skywriter; 07-20-2015 at 02:29 PM.

  13. #13
    Registered User
    Join Date
    07-20-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    70

    Re: Adding info from two tabs, to a third one using a macro Excel 2010

    I added the reputation. Thanks to both ptmuldoon and skywriter. You are the best!!!

+ 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. Attempting Macro to hide current tabs and create new ones with same info (Diff tab name)
    By theta25nupe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2014, 11:44 AM
  2. Replies: 4
    Last Post: 10-02-2013, 03:00 PM
  3. Extract info from excel 2010
    By stevejbailey in forum Excel General
    Replies: 3
    Last Post: 08-01-2013, 11:55 AM
  4. Excel 2010 - Cannot Add or Delete tabs
    By Shoultes in forum Excel General
    Replies: 6
    Last Post: 02-25-2013, 04:04 AM
  5. Can a macro change data on tabs when info in F7 of Job Info worksheet changes? If so How?
    By ILoveStMartin in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-05-2012, 02:59 AM
  6. [SOLVED] Finding Doc Info in Excel 2010
    By ChemistB in forum Excel General
    Replies: 2
    Last Post: 03-20-2012, 04:21 PM
  7. Adding new tabs, renaming it and adding info
    By marcos.cabrera in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2011, 11:18 AM

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