+ Reply to Thread
Results 1 to 23 of 23

Pulling data from a main sheet and placing it onto a newly created sheet

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Pulling data from a main sheet and placing it onto a newly created sheet

    I have a large set of data that is broken into regions that have a number value. ie 11, 15, 18 for example. I have code that will pull certain columns from this data set and place it into a new sheet, but it is coded in a way that if new data entry is input into a row it will screw up the entire thing. I would like to know if there is a way to have an input box that will search for a region number in Column A and then pull the given columns like in the previous code and place it onto a new sheet.

    sample of the original code is:
    Please Login or Register  to view this content.
    Last edited by arlu1201; 05-24-2012 at 09:16 AM. Reason: Please put code tags 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: Pulling data from a main sheet and placing it onto a newly created sheet

    Why dont you attach a sample file?
    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
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    I would like to just take the columns I,J,K. So when I enter say "15" I would be given rows 3-8. The code in the VB is just there for sample.
    Attached Files Attached Files

  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: Pulling data from a main sheet and placing it onto a newly created sheet

    Are you actually looking at transferring the various sections (groups) to individual sheets? Are you thinking of inputbox as 1 of the ways to do so?

  5. #5
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Yes I would like to transfer the various regions data to a new worksheet. I was hoping an inputbox could be used. What I want to happen (if possible), is for the macro to look up numbers in column A that correspond to the input box. Then it takes those specific columns (IJK) and places them into a new worksheet. What best describes this is just slicing the data up and moving to to a new sheet. Does that explain it better?

  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: Pulling data from a main sheet and placing it onto a newly created sheet

    If you run the macro once and all the sheets are created, when you run the macro again the next week, do you want the sheets to be cleared and fresh data inputted? Or should the data be copied into the next available row?

  7. #7
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    The next time this macro would be needed would be in a new workbook, so I would just need the macro to work. The new workbook would have the exact same format too, just the numbers and possibly the amount of variables in Column B would change.

  8. #8
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Any help would be great.

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

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button.
    Last edited by arlu1201; 05-25-2012 at 09:55 AM.

  10. #10
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Works splendid! One thing that I noticed and forgot to mention in my previous posts. It would be great if the the columns A,B went with, as to help understand the data in the created sheets. I'm guessing this will also cause a bit more code so hopefully you can bare with me on this :/

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

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    I corrected the code above to make the additions. Try it and let me know.

  12. #12
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Works marvelous! Thank you very much! There is a slight error that occurs after the last region number has been used and the macro creates a new sheet with nothing on it. Any way to fix that?

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

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Are you sure its a new sheet that is created and not the default sheet 2 or sheet 3 that you are seeing?

  14. #14
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Also, when i input it into my real workbook, the data being pulled is still correct but I am missing the row 2 information (sample workbook). This could be due to the fact that in my real workbook the data doesn't begin until row 6 and the information on row 5.
    Last edited by cbomination; 05-25-2012 at 09:18 AM.

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

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Quote Originally Posted by cbomination View Post
    Also, when i input it into my real workbook, the data being pulled is still correct but I am missing the row 2 information (sample workbook). This could be due to the fact that in my real workbook the data doesn't begin until row 6 and the information on row 5.
    How are you missing row 2? Do you mean that row 5 should be copied as the header to the new sheets?

  16. #16
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Yes, Row 2 in the sample workbook corresponds to Row 5 in my real workbook. So yea row 5 should be copied to the new sheets
    EDIT Sorry my laptop froze and didnt see my post
    Last edited by cbomination; 05-25-2012 at 09:27 AM.

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

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    I edited the code again. You can try it now.

  18. #18
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Yea, Row 2 in the sample workbook corresponds to row 5 in my real workbook. Rows are just shifted down. So yes i would like for the header (row 5 ) to copy over to the new sheets

  19. #19
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Alright the header shows up, but it needs to be shifted just one column to the right. Other than that THANK YOU SO MUCH! Do you add an offset?
    Last edited by cbomination; 05-25-2012 at 09:40 AM.

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

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    No i didnt use any offset. I just changed the number from 2 to 5 in this line
    Please Login or Register  to view this content.
    It copies the data to the new sheet cell A1.

    Edit: I edited the code to also add the headers for columns A & B. I forgot about them .

  21. #21
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Holy cow you are the best!!! Everything works great, and to answer your question earlier about that sheet being created with nothing on it. It is not sheet 2/3, it comes out to be "Sheet 45" whenever I run the macro. Its a very minor problem, it just brings up a stop in the code.

    Edit: This is just for further understanding. If I want to add more columns that were to be pulled into the other sheets, how would I do so?
    example
    .Range("R5:T5").Copy Worksheets(sname).Range("F1")

    would that copy columns R-T and place it starting at column F?
    Last edited by cbomination; 05-25-2012 at 10:08 AM.

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

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    I ran the macro on your sample sheet that you provided and i do not see it. Is it possible for you to upload the copy that you are using?

  23. #23
    Registered User
    Join Date
    05-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Pulling data from a main sheet and placing it onto a newly created sheet

    Sure, give me a sec to cut out some stuff so I can get under the limit

    Edit: I can't seem to get under 1MB, do you know how do get rid of a PivotTable format, but keep the data intact?
    Edit: Nevermind I got it! Thank you so much for sticking with me!
    Last edited by cbomination; 05-25-2012 at 10:52 AM.

+ 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