+ Reply to Thread
Results 1 to 12 of 12

how to write if function to assign values to multiple cells not only one

  1. #1
    Registered User
    Join Date
    08-20-2011
    Location
    qatar
    MS-Off Ver
    Excel 2007
    Posts
    9

    Thumbs up how to write if function to assign values to multiple cells not only one

    Hi everybody

    I,m new here

    my problem is as follows:

    I have Two excel sheets

    first sheet :has employees data with (id,name,job,department)
    second sheet :is a form which has
    1- three textboxes (name ,job,department)
    2-a label filled with the id of an employee

    what I want is to write if function to compare the id from the two sheets and when it is the same id ...I want the name ,job,department to be filled from the first sheet to the text boxes in the second sheet.


    more explanation:I want the if function to do multiple missions (to fill many cells with their values at once )

    so can I do this with if function and how ??

    I really appreciate any help cause I really need this in my new work


    thaxx in advance
    Last edited by Dalal; 08-29-2011 at 04:43 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: how to write if function to assign values to multiple cells not only one

    I think you really need VLOOKUP, see the example here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    08-20-2011
    Location
    qatar
    MS-Off Ver
    Excel 2007
    Posts
    9

    Talking Re: how to write if function to assign values to multiple cells not only one

    Hi RoyUK

    thaxx ...I think Vlookup is wat I need

    But I want Vlookup to bring data from multiple columns to multiple form boxes in the same time (by writing one function ) , maybe using a combination from ' if ' function and vlookup
    or a nested vlookup if this is possible ...

    I'm not sure about how this could be done .

    if a combination could be written, please write me a short example code for that

    Thank U again for helping .

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how to write if function to assign values to multiple cells not only one

    VLOOKUP() will provide all 3 pieces of information. You just need to edit the 3rd parameter to indicate which column in the vlookup range to return a value from.

    =VLOOKUP(A2, Sheet2!$A:$D, 2, 0)
    =VLOOKUP(A2, Sheet2!$A:$D, 3, 0)
    =VLOOKUP(A2, Sheet2!$A:$D, 4, 0)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    08-20-2011
    Location
    qatar
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: how to write if function to assign values to multiple cells not only one

    thaxx Jerry for help
    but wat u said is a three steps if i have a three columns

    wat i am asking is :
    can i merge those three steps in one

    i want my data to come from multiple columns into multiple form boxes in one shot


    wat may help is a macro which has all the vlookup together ...so can i do this ??

    I want the more professional solution if there is one .

    thaxx

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: how to write if function to assign values to multiple cells not only one

    You said:
    if a combination could be written, please write me a short example code for that.
    However you asked a very general question and got a very general answer. No one can write a macro with vapor data.
    You should have at least provided a sample workbook with some data that actually reflects your real workbook.
    You should also have tried to write your own macro by starting the macro recorder and recording all the steps you want.
    Then we can help you to generalize the macro to work at the click of a button.
    Ben Van Johnson

  7. #7
    Registered User
    Join Date
    08-20-2011
    Location
    qatar
    MS-Off Ver
    Excel 2007
    Posts
    9

    Wink Re: how to write if function to assign values to multiple cells not only one

    Hi
    I guess U r right i must give an example to wat i need ....sorry

    anyway I'm new in using functions in excel so I donno wat considered genral question and wat not .


    by the way when I said i want a professional solution i meant that I need your patience with me if I discussed more and more .

    But It seem U will kill me protonleah




    thxxxxxxxxx

    I liked this forum and I will stay here

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how to write if function to assign values to multiple cells not only one

    No onw is going to kill you and ProtonLeah isn't even being harsh with you. He's indicated useful things you can do to help us help you.

    So, are you going to provide more or are we done for now?
    Last edited by JBeaucaire; 08-21-2011 at 05:05 AM.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: how to write if function to assign values to multiple cells not only one

    Have you looked at my example workbook?

  10. #10
    Registered User
    Join Date
    08-20-2011
    Location
    qatar
    MS-Off Ver
    Excel 2007
    Posts
    9

    Wink Re: how to write if function to assign values to multiple cells not only one



    Thaxx all for helping >>>Yes... every thing is good and vlookup is working



    RoyUK ...yes I try your example and understand it ...I appreciate this


    But I have new questions about : isna and macros


    1- what is the work of (isna) and how to use it .

    2- how can i assign a value of a2 -as example - to b4 -as example -

    generally I want to put a [copy baste] operation in a larger macro

    --the value is diffrent in each sheet i want to apply the macro on -
    so i want the macro to take it as variable or cell value not as a static number




    I donno how to say more than thaxx .... how to say this ??

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: how to write if function to assign values to multiple cells not only one

    Why are you first asking for function help then move to macros?

  12. #12
    Registered User
    Join Date
    08-20-2011
    Location
    qatar
    MS-Off Ver
    Excel 2007
    Posts
    9

    Red face Re: how to write if function to assign values to multiple cells not only one

    when I registered here I wanted functions
    But during my work I needed macros to complete the work quickly .

    so I thought I can ask u here in same forum .

    But if this is against forum rules , I will ask in the macros forum


    obviously ... I got a job recently
    and my knowledge in excel is very simple ...
    I donno about vba coding or excel complex functions
    so with time I will need help in many random subjects .

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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