+ Reply to Thread
Results 1 to 12 of 12

Excel VBA If a cell contains a specific text then other cells will show specific vaules

  1. #1
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Excel VBA If a cell contains a specific text then other cells will show specific vaules

    Hi all,

    I have a drop down list that appears in cell C2, I want to write a macro where by different values will appear in cells I2>>O2 depending on what text is selected in the drop down box. So for example as attached, I have selected test 1 in cell C2 and values 0.5, 1, 1, 1, 1, 1, 0.5 appears in cells I2>>O2.

    Any help would be appreciated, I have been searching for previous posts for a while but cannot find the answer.

    Test1.PNG
    Last edited by elleb; 02-23-2017 at 04:03 PM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Does this help?

    Please Login or Register  to view this content.
    Just add another c2 = Case and what the outcome should be.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Hello elleb,

    You don't tell us what values any other selection should return.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Hello elleb,

    JOHN H. DAVIS gave you a good starting point with a VBA solution.

    If you don't want VBA, you could use formulas, such as;

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and then change it as shown in the VBA free sample attached below.

    Regards.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Hi Winon,

    Yes sorry, I thought that if I understood the coding for the first part I could figure the rest out myself. Trying to advance my VBA knowledge

  6. #6
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Hi John,

    I have added this but it still appears blank, should this be in a module or on the sheet that you specifically need it on?

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    It should be in a Standard Module, but can be modified for sheet code as well. Which would you prefer?

  8. #8
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Hi Winton,

    Sorry to ask, your sheet works really well. How to I get it from the formulas into a VBA format?

    ** Sorted it - thanks **
    Last edited by elleb; 02-23-2017 at 03:30 PM. Reason: solved this way

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Sheet Code version:

    Please Login or Register  to view this content.

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Thank you for the feedback elleb,

    I may be wrong, but please make sure you are using JOHN H. DAVIS's code with the correct reference regarding "Test1" and "Test 1" - Note the space after "Test", if any.

    Regards.

  11. #11
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Both work perfectly, thanks so much for your help.

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Excel VBA If a cell contains a specific text then other cells will show specific vaule

    Hello elleb,

    You are welcome, glad we could be of some help!

    Thank you for the "Rep", much appreciated.

    Regards.

+ 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] Enter data into a userform text box to show in a specific cell in a specific worksheet
    By Stevecraig211 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2016, 10:02 AM
  2. Show Userform if cell with specific text is pressed
    By mason0567 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2015, 10:26 PM
  3. Using Excel/ IF function to show a specific value/ text
    By Servert11 in forum Excel General
    Replies: 5
    Last Post: 03-27-2014, 10:18 AM
  4. excel return all cells containing in order if other cell contains specific text
    By vio.violeta in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-17-2014, 08:52 AM
  5. Replies: 3
    Last Post: 07-12-2013, 09:17 AM
  6. Macro to copy specific line from text file and paste into specific cell in excel
    By keeneye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 10:35 AM
  7. Replies: 1
    Last Post: 04-27-2012, 07:24 AM

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