+ Reply to Thread
Results 1 to 2 of 2

Setting values of multiple cells differently when a IF condition evaluates to true

  1. #1
    Registered User
    Join Date
    09-11-2020
    Location
    Melbourne
    MS-Off Ver
    Office 365
    Posts
    1

    Setting values of multiple cells differently when a IF condition evaluates to true

    Hello Guys

    I am unable to set values of multiple cells differently when an IF condition evaluates to true , below is snapshot of my macro code .

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("A1").Value = "John" And Range("A2").Value = "Mayor" Then
    Range("B1").Value = "Captain"
    Range("B2").Value = "Pro Division"
    End If

    End Sub

    I am relatively new to VBA so I suppose this might be a real basic thing , I could have done it using IF function in excel but that only allows upto 64 levels of nesting

    Thanks in advance

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,377

    Re: Setting values of multiple cells differently when a IF condition evaluates to true

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional.)
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. Replies: 2
    Last Post: 05-26-2015, 07:29 PM
  2. formula evaluates differently in VBA and immediate window
    By goldfrapp01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2014, 08:03 AM
  3. extract multiple cells if condition is true then next row
    By souch in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-17-2014, 02:39 PM
  4. [SOLVED] Only 1st condition of multiple IF conditions evaluates correctly
    By goodmma in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-23-2014, 02:12 PM
  5. How to copy each row where certain cell evaluates TRUE?
    By wwarren in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-27-2013, 03:58 PM
  6. Replies: 4
    Last Post: 01-08-2013, 09:04 AM
  7. Replies: 1
    Last Post: 08-20-2009, 10:58 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