+ Reply to Thread
Results 1 to 2 of 2

Target.Column problems

Hybrid View

  1. #1
    Registered User
    Join Date
    07-01-2009
    Location
    Bath, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Target.Column problems

    Im having some trouble with Target.Column / Target.Row syntax.

    The code below is a snippet of a conditional formatting problem that I posted about yesterday. I have been working on it since but cant seem to get it too work.

    When the if statements read:

    If Target >= (Range("H" & Target.Row).Value + Range("O15").Value + 2) Then icolor = 45
    rather than
    If Target >= (Range("H" & Target.Row).Value + Range(Target.Column & "15").Value + 2) Then icolor = 45
    They work, but obviously this is only relevant for column O.

    Any idea what I'm doing wrong??


    
    Dim icolor As Integer
        If Not Intersect(Target, Range("o16:ao35")) Is Nothing Then
               
            If Target = "" Then icolor = 2
                                
            If Target >= (Range("H" & Target.Row).Value + Range(Target.Column & "15").Value + 2) Then icolor = 45
            
            If Target >= (Range("H" & Target.Row).Value + Range(Target.Column & "15").Value + 10) Then icolor = 38
    
    
            Target.Interior.ColorIndex = icolor
    
        End If

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Target.Column problems

    Target.Column will return the number of the column so assuming Target was in P:

    Range(Target.Column & "15").Value
    will translate as

    Range("1615").Value
    which is obviously not valid syntax... you should perhaps revert to Cells based approach (R1C1) given it is significantly more flexible than using Range

    Cells(15,Target.Column).Value
    equates to

    Cells(15,16).Value
    which is R1C1 - ie Row 15 Column 16 which is equiv. to P15

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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