+ Reply to Thread
Results 1 to 12 of 12

How to fill cells from one worksheet to another

  1. #1
    Registered User
    Join Date
    02-27-2021
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS 2019
    Posts
    19

    Question How to fill cells from one worksheet to another

    Hello: I am trying to create a spread sheet to track what I eat and the associated nutrients. I have created one worksheet ( called "Food List") that lists the food and its nutrients in a row of cells( ie. Food name - Protein - Carbs - Sodium - Fats - Sugar ). I have given each food an ID #. What I would like to do next is on the worksheet I created ( called "Food Log") is to be able to enter the food ID# and have the food name and nutrients for that food to fill in a row of cells that are labeled the same as in the Food List worksheet.

    I'm kind of new at this any guidance would be appreciated

    Thanks
    kozz

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to fill cells from one worksheet to another

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    02-27-2021
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS 2019
    Posts
    19

    Re: How to fill cells from one worksheet to another

    Thank you Mehmetcik for helping.

    I have attached the workbook that has 3 worksheets.

    The Daily Diet Log worksheet ( one Empty and one Populated) is what I am trying to
    automatically fill when just entering the Food ID from the Food Nutrient Chart
    worksheet. For right now I will enter the date and time manually whenever I put in a Food ID number.


    Thanks
    kozz
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to fill cells from one worksheet to another

    formula for D9. =OFFSET(Sheet1!$A$1,MATCH($C9,Sheet1!$A:$A,0)-1,COLUMN()-3)

    Fill Right and down.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-27-2021
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS 2019
    Posts
    19

    Re: How to fill cells from one worksheet to another

    Thank you Mehmetcik. Tomorrow's task will be to try to figure out the formula you used to make it work and learn from that. I will also try to figure out how to get rid of the #N/A when there is no entry in the Food ID cell

    Thanks again for your help

    kozz

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to fill cells from one worksheet to another

    Formula for D8.

    =IF(C8="","",OFFSET(Sheet1!$A$1,MATCH($C8,Sheet1!$A:$A,0)-1,COLUMN()-3))

    1. =MATCH($C8,Sheet1!$A:$A,0) Match the contents of C8 in Column A of Sheet1. The $ fixes Column C and Column A as you fill right.

    2. =offset(Sheet1!$A$1, Row from 1. -1, Column -3) Return the Value of the Cell where the value is found offset by column -3)

    3. =IF($C8="","", Formula ) If Column C is empty then return nothing otherwise calculate the formula

  7. #7
    Registered User
    Join Date
    02-27-2021
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS 2019
    Posts
    19

    Re: How to fill cells from one worksheet to another

    Hi Mehmetcik. Thanks for your help. I understand most of what you did and why but I'm getting lost on the -1 of the MATCH part of the formula and on the COLUMN()-3 part. I tried to figure out why you did this but I don't see why. If you have time could you explain why you did this or direct me to an online explanation. I looked but could not find or understand

    Thanks
    kozz

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to fill cells from one worksheet to another

    We are looking at the offset function.

    We are offsetting from cell $A$1. The dollar signs fix the cell reference to A1 when we fill right or fill down.

    Enter 101 in cell C8 on Sheet1(3)

    So if we look for the code 101 it is in row 5 of sheet1.

    So we need to look at Row 5. If we offset A1 by 5 rows we end up looking at A6. Which is wrong. So Offset by 5 - 1 gives A5. So that explains the Minus 1.

    The first Cell that we are expecting a result in is Cell D8 on Sheet1(3) but we want that to return Data from Cell B5 in Sheet1.

    Ok So If We offset Cell A1 by the column number for column "D" ie 4 then our formula will return the contents E5 which is wrong. We want the contents of B5.
    So we offset A1 by the column number for column "D" ie 4 minus 3. This returns the contents of B5.

    At we fill right, the formula is adjusted and each cell returns the right data.

  9. #9
    Registered User
    Join Date
    02-27-2021
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS 2019
    Posts
    19

    Re: How to fill cells from one worksheet to another

    Hi Mehmetcik:

    I appreciate your help but I'm still confused about how/why D8 in Sheet1(3) plays in the OFFSET function when looking up a value in Sheet1. I would think it would be 1 column to the right of column A in Sheet1. I played with the formula by changing some number for the columns but it didn't come back with the right value and i don't understand why

    Thanks for your help
    kozz

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to fill cells from one worksheet to another

    If Cell C8 on Sheet1(3 Contains 101 then

    We want Cell D8 on Sheet1(3 to return "Apple Sauce (no sugar)" which is the contents of Cell B5 on Sheet1

    B8 = Cell A1 on Sheet1 offset by 4 rows and 1 column

    = Cell A1 on Sheet1 offset by the (row number of A5-1 ) =4 and the column of (D8 -3) =1

  11. #11
    Registered User
    Join Date
    02-27-2021
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS 2019
    Posts
    19

    Re: How to fill cells from one worksheet to another

    Thanks Mehmetcik: I think I understand now... I think!. However, I do not understand why the same formula ( nothing changes) is used for all the cells in a row. Shouldn't the formula for E8 on sheet1(3) be different than D8? The data for E8 comes from C5 on sheet1 so shouldn't the formula have a -4 instead of a -3 when referencing A1?

    Thanks for answering all my questions
    kozz

  12. #12
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to fill cells from one worksheet to another

    Ok.

    You are not understanding that the column() function returns the column number of the cell it is in.
    So in D8 Column() returns 4 and in E8 it returns 5.


    The formula in D8 is =IF($C8="","",OFFSET(Sheet1!$A$1,MATCH($C8,Sheet1!$A:$A,0)-1,COLUMN()-3))

    The $ signs mean that the column numbers do not change as we fill right so the formula in E8 is still:-

    =OFFSET(Sheet1!$A$1,MATCH($C8,Sheet1!$A:$A,0)-1,COLUMN()-3))

    So =OFFSET(Sheet1!$A$1,MATCH($C8,Sheet1!$A:$A,0)-1,COLUMN()-3)

    Offset Cell A1 in Sheet1 by ( 5-1 ) rows and Column number for cell E8 -3 columns

    ie

    Offset Cell A1 in Sheet1 by 4 rows and Column number for cell 2 columns

    This returns the contents of C5.

+ 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. how to set worksheet to fill in cells in suquencial order
    By jenLumetta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2017, 09:13 PM
  2. How do I auto fill cells from another worksheet
    By cal348 in forum Excel General
    Replies: 1
    Last Post: 03-01-2017, 10:38 AM
  3. [SOLVED] How to fill only blank cells based on another worksheet
    By meprad in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-26-2013, 04:13 AM
  4. [SOLVED] Auto fill cells getting value from different worksheet but only if conditions met
    By zigojacko in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-17-2013, 03:55 AM
  5. Select Row and auto fill cells in another worksheet
    By mcm1009 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2011, 05:13 AM
  6. fill cells with even increment rows from a different worksheet
    By FormulaChallenged in forum Excel General
    Replies: 4
    Last Post: 12-07-2005, 04:45 PM
  7. [SOLVED] Making cells compulsary to fill in on a worksheet
    By abfabrob in forum Excel General
    Replies: 7
    Last Post: 02-03-2005, 09:06 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