+ Reply to Thread
Results 1 to 6 of 6

Macro for pulling cell data from one worksheet onto another

  1. #1
    Registered User
    Join Date
    02-28-2014
    Location
    Minneapolis, MN
    MS-Off Ver
    O365
    Posts
    9

    Macro for pulling cell data from one worksheet onto another

    I need some help with a macro to use on a worksheet that would be able to search and grab cell data from another work sheet and enter it in the main worksheet.

    I have 3 worksheets: Input Log, Dispense Log, and Formulary Table. The Formulary Table contains a list of UPC's (Column A) and the corresponding Product Name (Column B), Brand (Column C), and Package Size (Column D).

    What I am looking for is an ability to hotkey a window under the Input Log worksheet that would prompt for the UPC, a quantity, and the employees Initials and then would enter those fields in the respective columns in the Input Log worksheet. [UPC in Column A, Quantity in Column E, and Initials in Column G]. I then need the macro to take the UPC entered in Column A in the Input worksheet and search the Formulary Table for a match. Then take the data from Columns B, C, and D in that same row and populate the cells in Columns B, C, and D in the corresponding UPC row in the Input worksheet.

    Is there a way to have the data automatically be entered in the next open row below the current data set? I'm not very good at writing Macros in Excel so any help would greatly be appreciated! Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Macro for pulling cell data from one worksheet onto another

    There is absolutely a way, but I find it fairly difficult to write VBA from scratch without some sample data to test on. do you already have your userform working? and the hotkeys assigned? Can you upload a sample workbook?

    general pointers for your last question - it's fairly common to declare a long variable which you can set to the last used row with some code like this:
    Please Login or Register  to view this content.
    then you can copy values to .Range("A" & lr + 1) to print in the next open row.

    remember you'll need to redefine lr at this point (if you're running a loop you can do so at the start of the loop or at the end just do lr = lr + 1)


    **Additional info**
    As for matching your UPC code, i've been using the find() method quite a bit lately - typically in some sort of a loop along these lines:
    Please Login or Register  to view this content.
    (untested)

    that could probably be cleaner if you declared a few more variables or resized the ranges or something
    Last edited by simarui; 04-10-2015 at 11:27 AM. Reason: adding info for the UPC match request
    Hope I could help - if your post has been solved don't forget to mark it as such.

    Clicking the * below is a great way to say thanks!

    "Drowning in 10 feet of water isn?t any different than drowning in a million feet. And if you can swim, it doesn?t matter how deep the ocean is. At some level, once you realize you?re in water that?s too deep to stand, you have to have a very different approach," - Joi Ito

  3. #3
    Registered User
    Join Date
    02-28-2014
    Location
    Minneapolis, MN
    MS-Off Ver
    O365
    Posts
    9

    Re: Macro for pulling cell data from one worksheet onto another

    C-II Log Test.xlsm

    This is the workbook I am currently working with. I went with a userform command button instead of a hotkey. Still having some trouble figuring out how to pull the cell data from Sheet4 onto Sheet 2 or Sheet 3. Does this provide any clarity?

    Thanks again.

  4. #4
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Macro for pulling cell data from one worksheet onto another

    looks like this is working

    Please Login or Register  to view this content.
    as attached
    Attached Files Attached Files
    Last edited by simarui; 04-15-2015 at 09:29 AM. Reason: added attachment

  5. #5
    Registered User
    Join Date
    02-28-2014
    Location
    Minneapolis, MN
    MS-Off Ver
    O365
    Posts
    9

    Re: Macro for pulling cell data from one worksheet onto another

    Thanks simarui! That works perfect

  6. #6
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Macro for pulling cell data from one worksheet onto another

    glad i could help and thanks for the rep! don't forget to mark the post solved

+ 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] Pulling row data to new worksheet based on values on row cell
    By afrazier25 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-26-2015, 02:50 PM
  2. [SOLVED] Macro pulling & copying data from a very hidden worksheet
    By backyardfun in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2013, 10:29 AM
  3. [SOLVED] Pulling different data from 1 cell via macro
    By Bax in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2013, 09:23 AM
  4. [SOLVED] An Excel Macro for Pulling in Data from Another Worksheet Using A Search Cell
    By ereisman in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 03-07-2013, 01:52 PM
  5. Pulling a Specific Cell when Pulling a Tabel from Web Based Data
    By Zallen89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2013, 05:39 PM

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