+ Reply to Thread
Results 1 to 5 of 5

Running Macro Based on Cell

  1. #1
    Registered User
    Join Date
    04-05-2021
    Location
    New York
    MS-Off Ver
    2013
    Posts
    15

    Running Macro Based on Cell

    Hello, I am trying to have a macro run such that when a list in cell F11 = "2P", cells C11&C12 merge.

    I have done some research on this, and understand I cannot simply use and If statement in cell C11, but using VBA has not seem to work to recognize the cells value.

    My coding skills are not terrible, but I am not exactly well educated on VBA coding.

    If there is a better way than using a macro, I would like to hear it.

    Thanks for any help.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Running Macro Based on Cell

    Code not in Module, code in WorkSheet Change Event

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-05-2021
    Location
    New York
    MS-Off Ver
    2013
    Posts
    15

    Re: Running Macro Based on Cell

    Thank you for the help. I have tweaked the code to test it for my needs.

    Is there a way to set the range for F11:52 so that it can recognize each row, and change only the associated rows? The below code is an example of how the value of F11 effects C11:13 & D11:13.

    If Target.Address = "$F$11" Then
    If Target.Value = "2P" Then Range("C11", "C12").Merge
    If Target.Value = "2P" Then Range("D11", "D12").Merge
    If Target.Value = "2P" Then Range("C12").Borders(xlInsideHorizontal).LineStyle = xlContinuous
    If Target.Value = "3P" Then Range("C11", "C13").Merge
    If Target.Value = "2P" Then Range("D11", "D13").Merge
    If Target.Value = "1P" Then Range("C11", "C13").UnMerge
    If Target.Value = "1P" Then Range("C11", "C13").Borders(xlInsideHorizontal).LineStyle = xlContinuous
    If Target.Value = "1P" Then Range("D11", "D13").UnMerge
    If Target.Value = "1P" Then Range("D11", "D13").Borders(xlInsideHorizontal).LineStyle = xlContinuous
    End If

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Running Macro Based on Cell

    Maybe

    Please Login or Register  to view this content.
    Kind regards
    Leo

  5. #5
    Registered User
    Join Date
    04-05-2021
    Location
    New York
    MS-Off Ver
    2013
    Posts
    15

    Re: Running Macro Based on Cell

    Select Case... I always forget about that method. I had to tweak the code a little, but that worked out well. Thank you!

+ 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] Running a macro based on a cell value
    By raewyn64 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-13-2018, 08:20 AM
  2. [SOLVED] Running a Macro based on a cell reference
    By JLeith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2016, 03:01 AM
  3. Running Macro based on value of a certain cell.
    By birminghamguy86 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2011, 06:41 AM
  4. Running Macro based on a cell being equal to specific value
    By mbrady1973 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2009, 07:11 AM
  5. Running Macro based on Cell value
    By titovalle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2007, 02:53 PM
  6. Running a macro based on a value
    By Jeanne Conroy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2006, 06:25 PM
  7. [SOLVED] Running a macro based on a cells value
    By Piwo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-18-2005, 04: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