+ Reply to Thread
Results 1 to 21 of 21

Extracting and transferring data across sheets

  1. #1
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Extracting and transferring data across sheets

    Hi,
    I'm trying to write the code to get certain rows of data on one sheet to transfer to another sheet. The data sheet is denoted "Sheet1" and the compiled sheet is denoted "Sheet2". The compiled sheet has one row of input that includes values as well as 8 categories/classifications. If all of those 8 categories match an entry in the data sheet, then the entire row will be transferred to the compiled sheet. All of the data fields match up in each sheet; that is, the qualifications are in columns 19-26 in both. The rows to be transferred will include columns 2-26, and will go into the second sheet starting at row 3.
    I'm using nested looping structures to do this, and what I have seems as if it'll make sense, but when I go to run it, there is a type mismatch. The part that gets highlighted is at the very beginning: Private Sub Transfer()
    What am I doing wrong?

    -------------------------------------------------------

    Please Login or Register  to view this content.
    Last edited by arlu1201; 06-18-2012 at 09:32 AM. Reason: Code tags. Please put them in future.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    I have not checked if your code does what its supposed to, but i have corrected it so it shouldnt give you any errors. Try this
    Please Login or Register  to view this content.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    Thank so much! But when I tried it it said "subscript out of range", but didn't give any indication where the code is faulty.. ?

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    Are you still getting the error? Check if your sheets are named as "Sheet1" and "Sheet2" as per the code.

  5. #5
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    I checked the names, there was one error, so now it doesn't display the error message. But nothing happens when I run the macro

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    Can you upload the file you are using with the macro? Remove any sensitive data.

  7. #7
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    Here, I made a dummy file using all the same code/formatting as the one that I'm working on. Thank you for your help!!
    Dummy Program.xlsm

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    I click on Enter data button on sheet2 and got the form. I filled it up and the data came into Sheet2.

    Now i didnt see any button called "Transfer" to move the data to Sheet1. How is that code triggered?

    Also, you need to place that code in a module and not in the "ThisWorkbook" section.

  9. #9
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    I hadn't set up an ActiveX control button yet, I had just opened it in Visual Basic and used the run button, which had worked when I was developing the other macros.
    And okay, thanks, I didn't know that had to be a module, I'll change that.
    Also, there should only be one line of input data on Sheet2 (very specific work project), so those qualities of one row are the only ones to be checked against the sheet of other data.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    Ok..did you try running the macro after putting it in the module? Did you get any error? If you got an error, when you clicked on debug, which line of code was highlighted?

  11. #11
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    The part that was highlighted was the part where I was trying to find the last row:
    Lastrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp)

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    Change it to

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    It still highlights as "subscript out of range" :/ Thank you though

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    Is your sheet named "Sheet1"?

    If yes and it still does not work try this
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    Yes it is named Sheet1... same error with that code too

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    Can you attach the file that you are using? Remove the sensitive data.

  17. #17
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    Here's what I have.. I've tried lots of different things but this is all I have that's solid.
    There is already input in sheet2 so there's no need to have to populate it with the form. Also I haven't programmed the Transfer button to open the macro yet; I was still doing everything in the VBA editor.
    Comparison Program.xlsm

  18. #18
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    Bump?? Still haven't figured this out

  19. #19
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    I made some more corrections to your code. Run it and see if it gives you what you need.
    Please Login or Register  to view this content.
    The Private Sub CommandButton3_Click() you see is for the Transfer button. Its named as CommandButton3 in the backend.

  20. #20
    Registered User
    Join Date
    06-18-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Extracting and transferring data across sheets

    Wow thanks so much!!!
    It does transfer the data, but doesn't return in the right format (nothing is on the same row), so I'll just tweak it a little bit.

  21. #21
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Extracting and transferring data across sheets

    Yeah i noticed that but didnt know in what format you want the output, so i didnt change anything.

+ 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.6.0 RC 1