Consulting

Results 1 to 5 of 5

Thread: Solved: Condition with StatusBar based on Row number

  1. #1

    Solved: Condition with StatusBar based on Row number

    Hi everyone

    This handy code was written by xld yesterday.
    How can make (statusbar = False) if current row number is < 6 or > 60?

    [vba]Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    On Error Resume Next

    If Me.Range("B" & Target.Row).Value = "" Then

    Application.StatusBar = False

    Else

    Application.StatusBar = _
    Me.Range("B" & Target.Row).Address(False, False) & ": " & Me.Range("B" & Target.Row).Value & ", " & _
    Me.Range("BR" & Target.Row).Address(False, False) & ": " & Me.Range("BR" & Target.Row).Value & ", " & _
    Me.Range("BS" & Target.Row).Address(False, False) & ": " & Me.Range("BS" & Target.Row).Value & ", " & _
    Me.Range("BT" & Target.Row).Address(False, False) & ": " & Me.Range("BT" & Target.Row).Value

    End If

    End Sub
    [/vba]

  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 Range)
    Const WS_RANGE As String = "6:60"
    On Error Resume Next

    If Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

    Application.StatusBar = False

    Else

    Application.StatusBar = _
    Me.Range("B" & Target.Row).Address(False, False) & ": " & Me.Range("B" & Target.Row).Value & ", " & _
    Me.Range("BR" & Target.Row).Address(False, False) & ": " & Me.Range("BR" & Target.Row).Value & ", " & _
    Me.Range("BS" & Target.Row).Address(False, False) & ": " & Me.Range("BS" & Target.Row).Value & ", " & _
    Me.Range("BT" & Target.Row).Address(False, False) & ": " & Me.Range("BT" & Target.Row).Value

    End If

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thank you xld again. But I noticed that you removed the condition that test the value of Column "B" if it is nothing

    [VBA]
    If Me.Range("B" & Target.Row).Value = "" Then

    Application.StatusBar = False[/VBA]

    How can i test both of them?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Of course you can. I thought that you had used that to show what you want.

    [vba]

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Const WS_RANGE As String = "6:60"
    On Error Resume Next

    If Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Or _
    Me.Cells(Target.Row, "B").Value = "" Then

    Application.StatusBar = False
    Else

    Application.StatusBar = _
    Me.Range("B" & Target.Row).Address(False, False) & ": " & Me.Range("B" & Target.Row).Value & ", " & _
    Me.Range("BR" & Target.Row).Address(False, False) & ": " & Me.Range("BR" & Target.Row).Value & ", " & _
    Me.Range("BS" & Target.Row).Address(False, False) & ": " & Me.Range("BS" & Target.Row).Value & ", " & _
    Me.Range("BT" & Target.Row).Address(False, False) & ": " & Me.Range("BT" & Target.Row).Value
    End If

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Thank you very much xld.

Posting Permissions

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