+ Reply to Thread
Results 1 to 6 of 6

VBA to add text into a range of cells if another cell has a specific value

  1. #1
    Registered User
    Join Date
    08-30-2012
    Location
    Meriden, England
    MS-Off Ver
    Excel 2016
    Posts
    20

    VBA to add text into a range of cells if another cell has a specific value

    I'd be grateful with some vba coding advice.

    What I am trying to do is add a word "dummy" into a range of cells (T5:T39) if cell X47 ="0"

    The code would need to run whenever the sheet is open.

    I can do this a formula, but the range of cells (T col) are already populated automatically with that info coming via an api

    Would I insert this as a module?

    As always any help appreciated
    Last edited by steve64; 02-21-2016 at 12:13 PM.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA to add text into a range of cells if another cell has a specific value

    This would be placed in the worksheet module for the sheet you want the code to run on.
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    08-30-2012
    Location
    Meriden, England
    MS-Off Ver
    Excel 2016
    Posts
    20

    Re: VBA to add text into a range of cells if another cell has a specific value

    Thanks Tom, much appreciated.
    I have inserted the code in the worksheet module and saved it.
    This runs a treat when I click run. But when the cell value changes nothing happens. Am I doing something wrong?
    Cheers
    Steve

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA to add text into a range of cells if another cell has a specific value

    I thought you wanted the code to run when the sheet was selected so I wrote the code for that. If you want it to run when the value in X47 is changed then change the sub title from
    this...
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-30-2012
    Location
    Meriden, England
    MS-Off Ver
    Excel 2016
    Posts
    20

    Re: VBA to add text into a range of cells if another cell has a specific value

    Perfect
    Thanks for your time and expertise Tom

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA to add text into a range of cells if another cell has a specific value

    No problem, glad I could help.

+ 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] VBA to Find Specific Text, then Copy range to next open cell under specific text
    By Remotruker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2015, 10:59 AM
  2. Replies: 2
    Last Post: 08-05-2013, 07:32 PM
  3. Replies: 2
    Last Post: 05-31-2013, 12:01 AM
  4. [SOLVED] Return specific text if a different text is contained anywhere in a range of cells
    By ciayers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 05:54 PM
  5. [SOLVED] Highlight a range of cells if a single cell contains specific text
    By ZHertz in forum Excel General
    Replies: 3
    Last Post: 10-19-2012, 02:54 PM
  6. Replies: 7
    Last Post: 07-30-2012, 01:31 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