Consulting

Results 1 to 11 of 11

Thread: Solved: conditional formating offset

  1. #1
    VBAX Tutor CCkfm2000's Avatar
    Joined
    May 2005
    Posts
    209
    Location

    Solved: conditional formating offset

    hi all,

    the following conditional formating works, I need offset the formating column H.


    [vba]Private Sub worksheet_selectionchange(ByVal target As Excel.Range)
    Dim rnArea As Range
    Dim rnCell As Range
    Set rnArea = Range("e57:e90")
    For Each rnCell In rnArea
    With rnCell
    If Not IsError(.Value) Then
    Select Case .Value
    Case "1"
    .Interior.ColorIndex = 38
    Case "2"
    .Interior.ColorIndex = 40
    Case "3"
    .Interior.ColorIndex = 36
    Case "4"
    .Interior.ColorIndex = 35
    Case "5"
    .Interior.ColorIndex = 34
    Case "6"
    .Interior.ColorIndex = 15
    Case "7"
    .Interior.ColorIndex = 39
    Case "8"
    .Interior.ColorIndex = 7
    Case "9"
    .Interior.ColorIndex = 44
    Case "10"
    .Interior.ColorIndex = 6
    Case "11"
    .Interior.ColorIndex = 4
    Case "12"
    .Interior.ColorIndex = 8
    Case "13"
    .Interior.ColorIndex = 3
    Case "14"
    .Interior.ColorIndex = 46
    Case "15"
    .Interior.ColorIndex = 43

    End Select
    End If
    End With
    Next
    Application.Calculation = xlCalculationAutomatic
    End Sub
    [/vba]


    any ideas?

    thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub worksheet_selectionchange(ByVal target As Excel.Range)
    Dim rnArea As Range
    Dim rnCell As Range
    Set rnArea = Range("e57:e90")
    For Each rnCell In rnArea
    With rnCell
    If Not IsError(.Value) Then
    Select Case .Value
    Case "1"
    .Offset(0,3).Interior.ColorIndex = 38
    Case "2"
    .Offset(0,3).Interior.ColorIndex = 40
    Case "3"
    .Offset(0,3).Interior.ColorIndex = 36
    Case "4"
    .Offset(0,3).Interior.ColorIndex = 35
    Case "5"
    .Offset(0,3).Interior.ColorIndex = 34
    Case "6"
    .Offset(0,3).Interior.ColorIndex = 15
    Case "7"
    .Offset(0,3).Interior.ColorIndex = 39
    Case "8"
    .Offset(0,3).Interior.ColorIndex = 7
    Case "9"
    .Offset(0,3).Interior.ColorIndex = 44
    Case "10"
    .Offset(0,3).Interior.ColorIndex = 6
    Case "11"
    .Offset(0,3).Interior.ColorIndex = 4
    Case "12"
    .Offset(0,3).Interior.ColorIndex = 8
    Case "13"
    .Offset(0,3).Interior.ColorIndex = 3
    Case "14"
    .Offset(0,3).Interior.ColorIndex = 46
    Case "15"
    .Offset(0,3).Interior.ColorIndex = 43

    End Select
    End If
    End With
    Next
    Application.Calculation = xlCalculationAutomatic
    End Sub
    [/vba]

  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Not tested but perhaps something like[VBA]
    If Not IsError(.Value) Then Select Case .Value
    Case "1"
    .Interior.ColorIndex = 38
    .Offset(0,3).interior.colorindex=38
    Case "2"
    .Interior.ColorIndex = 40

    [/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Ouch! My poor toes.

  5. #5
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    You're too quick Bob!, i did think he wanted to format the offset TOO!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  6. #6
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    cant even beat you to a quip!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I'll slow down, wait to see if you are posting (got to do some work anyway, some of us don't have the luxury of working for big corporations).

  8. #8
    VBAX Tutor CCkfm2000's Avatar
    Joined
    May 2005
    Posts
    209
    Location
    thats great thanks all.

  9. #9
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Not at work, i have a slipped disc and inflammation of the sacrialiac joint!
    not sure of the spelling of that.

    not too bad now back to work in a week!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    There I go, foot in again.

    Sorry to hear that, hope it gets better soon. No wonder you are here, anything to take your mind off it!

    PS I think it is spelt sacroiliac.

  11. #11
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    RSS feed?
    lol
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •