+ Reply to Thread
Results 1 to 9 of 9

Need a Lookup or IF statement within a MACRO?

  1. #1
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Need a Lookup or IF statement within a MACRO?

    I've attached a sample (an extracted small component of a larger workbook) of a macro that is almost working.

    In Sheet1 a user can enter Key Indicators, Key measures and enter formulas for the Key Measures. These formulas are then transposed to the "Employee Report" sheet.
    There is no data attached to this sample workbook, so all the formulas will result in 0.

    I've recorded a simple Macro that works fine. Problem is, no matter what formula I write or change (in Sheet1 row 67 through 78), only row 114 in Employee Report is updated.

    I want for the Macro to find a match in the Employee Report for Department (Column A), the Measurement (Column E) and then populate the matching row with the formula that was entered for that department and measurement in Sheet1.
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need a Lookup or IF statement within a MACRO?

    Hi,

    See the attached which uses the following procedure. Sheet1 A66 has also been given the range name 'TopRow'

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: Need a Lookup or IF statement within a MACRO?

    Thanks Richard! This works great.

    One other question:
    In my workbook the client/user will create their own department names, and thus the department names will be different for each client. How do I change in your code the: Case Is = "Marketing" to have the word "Marketing" change when the user has changed the name for that Department (which is done in a separate sheet)? Can we have it point to the Column header in Sheet1? like: Case Is = "Sheet1 $C$2"

    The workbook I shared is only a small sample, there are up to 20 departments available to the user.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need a Lookup or IF statement within a MACRO?

    Quote Originally Posted by johnw993 View Post
    Thanks Richard! This works great.

    One other question:
    .....Can we have it point to the Column header in Sheet1? like: Case Is = "Sheet1 $C$2"
    The workbook I shared is only a small sample, there are up to 20 departments available to the user.
    [/QUOTE=johnw993;3098522]

    Yes that would seem a reasonable way forward. So
    Case = Sheet1.Range("C2")
    ..etc

  5. #5
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: Need a Lookup or IF statement within a MACRO?

    Works like a charm! Thanks Richard!

  6. #6
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: Need a Lookup or IF statement within a MACRO?

    Perhaps you can help me out with another issue?:

    I've created a Userform to enter (new) employee information, such as name, department, title, salary, etc. etc.
    It contains a number of ComboBoxes and TextBoxes. All ComboBoxes contain lists of data from ranges.
    My question: I want to be able to edit an existing employee's information using the same form, and have each Combo and Textbox show the information belonging to the employee when I select that name in the first ComboBox.
    All data entered in this form is stored in a database (Table) in a separate sheet.
    Other people have suggested I replace all other comboboxes with textboxes, but I don't want to do that. Using the Comboboxes helps guide the user and ensures consistency in data entry.
    See below the code for the UserForm (called Admin).

    (You can ignore the bottom part of the code. I'm experimenting with code to populate the database without using Tables. On the MAC you can not have multiple users using your model simultaneously if you are using Tables....)


    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: Need a Lookup or IF statement within a MACRO?

    Perhaps you can help me out with another issue?:

    I've created a Userform to enter (new) employee information, such as name, department, title, salary, etc. etc.
    It contains a number of ComboBoxes and TextBoxes. All ComboBoxes contain lists of data from ranges.
    My question: I want to be able to edit an existing employee's information using the same form, and have each Combo and Textbox show the information belonging to the employee when I select that name in the first ComboBox.
    All data entered in this form is stored in a database (Table) in a separate sheet.
    Other people have suggested I replace all other comboboxes with textboxes, but I don't want to do that. Using the Comboboxes helps guide the user and ensures consistency in data entry.
    See below the code for the UserForm (called Admin).

    (You can ignore the bottom part of the code. I'm experimenting with code to populate the database without using Tables. On the MAC you can not have multiple users using your model simultaneously if you are using Tables....)


    Please Login or Register  to view this content.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need a Lookup or IF statement within a MACRO?

    Hi,

    Since this is a different request then you should start another thread with a different and appropriate title. This is a forum requirement since it assists others who may be searching for a similar situation.

    I suggest you close this thread as SOLVED and create another.

    Regards

  9. #9
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: Need a Lookup or IF statement within a MACRO?

    Sorry Richard, I'm still somewhat new to this venue and appreciate your advice. Will repost this as a new thread.

+ 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