+ Reply to Thread
Results 1 to 4 of 4

Using named range cells

  1. #1
    Registered User
    Join Date
    09-29-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Microsoft Office 365
    Posts
    3

    Using named range cells

    Hi everyone!
    I'm a bit new using VBA and was wondering if anyone could help me out in this... I'll have a lot of this type of situation to put and am looking for the clearest way to write VBA to get this done.

    Column C is the values in the list of B1 (in green).
    I woule like to have that If B1 = C1, then D1 is in .interior.colorindex = 37

    The thing is, A1:D5 is a named range ("CTB1_NSF")

    How is it possible to have that? The coding below always puts D1:D2 in .ColorIndex 37 and I don't know why...

    Thanks!

    Private Sub Worksheet_Change(ByVal Target As Range)
    With Range("CTB1_NSF_dernierterme")
    If .Cells(1, 2).Value = "" Then .Cells(i, 4).Interior.ColorIndex = 2
    If .Cells(1, 2) = Cells(1, 3) Then .Cells(1, 4).Interior.ColorIndex = 37
    If .Cells(1, 2) = Cells(2, 3) Then .Cells(2, 4).Interior.ColorIndex = 37
    If .Cells(1, 2) = Cells(3, 3) Then .Cells(3, 4).Interior.ColorIndex = 37
    If .Cells(1, 2) = Cells(4, 3) Then .Cells(4, 4).Interior.ColorIndex = 37
    If .Cells(1, 2) = Cells(5, 3) Then .Cells(5, 4).Interior.ColorIndex = 37
    End With
    End Sub
    Attached Files Attached Files

  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,436

    Re: Using named range cells

    Your example file does not have any Named Ranges nor any code. Please provide a better sample.
    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


  3. #3
    Registered User
    Join Date
    09-29-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Microsoft Office 365
    Posts
    3

    Re: Using named range cells

    OK here is one with the programmed macro in...
    Thanks
    Attached Files Attached Files

  4. #4
    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,436

    Re: Using named range cells

    Try:

    Please Login or Register  to view this content.
    Note the extra dots/points/stops/whatever

+ 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. Named range using indirect and cells containing range strings
    By vikas.trades25 in forum Excel General
    Replies: 12
    Last Post: 05-08-2019, 02:28 PM
  2. Listbox displaying named range B but Adding named range A to cell
    By ikkenieikke in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-05-2018, 02:27 PM
  3. [SOLVED] Compare cells to named range and create new sheets using related named range
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-10-2015, 03:35 PM
  4. Dynamic / Named Print Range To Include Another Range of Cells
    By thekrakenwakes in forum Excel General
    Replies: 0
    Last Post: 07-25-2014, 07:52 AM
  5. [SOLVED] Determine what Named Range the Target Address is and return Named Range Name
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-18-2012, 10:49 PM
  6. Replies: 1
    Last Post: 06-03-2006, 10:55 PM
  7. Compare a selected Range with a Named range and select cells that do not exist
    By PCLIVE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2005, 03:05 PM

Tags for this Thread

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