+ Reply to Thread
Results 1 to 13 of 13

Code to pulling specific data from a sheet

  1. #1
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Code to pulling specific data from a sheet

    I have one sheet which is comprised of data that was imported from a web page. In a second sheet I have a cell asking for min price and max price which comes from the imported data. The min price is the 1st number and the max price is the second number. The issue is that the data can move to different cells when it's refreshed so my code needs to look for some specific wording to find the prices that I need rather than just directing it to the same cell each time.

    The prices will always be in this string found on the cattle summary sheet, the prices are the numbers after lbs:

    SLAUGHTER BULLS: Yield grade 1-2 1000-1500 lbs 0.00-0.00;
    1500-2000 lbs 71.00-75.00.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to pulling specific data from a sheet

    Is this a process that is too difficult to explain? I thought someone would have a simple answer but I cant seem to get any help with this. Very frustrating

  3. #3
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,164

    Re: Code to pulling specific data from a sheet

    There are many tabs in your attached file. Which is the tab we need to work with?

  4. #4
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to pulling specific data from a sheet

    I need to pull the data from USDA cattle summary tab and bring it to the cattle prices tab.

    this is found in the cattle summary tab
    SLAUGHTER BULLS: Yield grade 1-2 1000-1500 lbs 0.00-0.00;
    1500-2000 lbs 71.00-75.00.


    the price 71 needs to go to the min cell in cattle prices
    75 needs to go the max prices.

    we were told to use the following VBA functions to accomplish this (InStr, Len, Mid, Val)
    the low and high price need to be stored in variables dimessioned as single.
    Also we were told to use a for next loop to go through rows 15-35 in the USDA tab to search for the prices as they can move when that page is refreshed.

    I have basically very little knowledge or background in VBA so I really don't know what any of that means.

  5. #5
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,164

    Re: Code to pulling specific data from a sheet

    The USDA tab is completely blank in your attachment. Can you please re-attach the complete file? There are some good experts on this forum who will surely help you out with the functions you need help with.

  6. #6
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to pulling specific data from a sheet

    Oh, maybe that is the problem. I only have excel 2003 on this computer so I couldn't view that file. Here is the file in 2003 with all the information. Hopefully the coding is the same for both versions.

    Thanks
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to pulling specific data from a sheet

    I guess that didn't clarify my issue. I feel as though I'm asking or describing the issue wrong and that's why I'm not getting anywhere here. I just don't know how to explain it any better. The code needed is for a macro that will automatically find this info from the other sheet no matter where it is on the sheet. I guess that's the best I can put it. It may be time to give up

  8. #8
    Forum Guru
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Code to pulling specific data from a sheet

    hi, pnaquin, please check attachment, run code "test"
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to pulling specific data from a sheet

    Thank you so very much!!! That seems to work. Would it continue to work if that data was refreshed and the prices were located in a different cell?

  10. #10
    Forum Guru
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Code to pulling specific data from a sheet

    as soon as SLAUGHTER BULLS and next next line will go in pair yes it should work as expected

  11. #11
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to pulling specific data from a sheet

    Again thank you very much. Just one last question that I forgot. I also need to extract the data which will always be A5 and send it that cattle prices sheet. But it needs to be stored into a variable named PriceDate and I need to dimension it with a Date data type

    I used macro recorder to just copy the date and paste in the cell but doesn't dimesion anything. How would I do that?

  12. #12
    Forum Guru
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Code to pulling specific data from a sheet

    please check attachment
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    10-25-2011
    Location
    baton rouge, louisiana
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to pulling specific data from a sheet

    Thanks again, you have been so helpful.

+ 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