PDA

View Full Version : Solved: Condition with StatusBar based on Row number



Ctrl
05-16-2008, 06:22 AM
Hi everyone

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

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

Bob Phillips
05-16-2008, 06:47 AM
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

Ctrl
05-16-2008, 07:24 AM
Thank you xld again. But I noticed that you removed the condition that test the value of Column "B" if it is nothing


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

Application.StatusBar = False

How can i test both of them?

Bob Phillips
05-16-2008, 07:38 AM
Of course you can. I thought that you had used that to show what you want.



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

Ctrl
05-16-2008, 07:46 AM
Thank you very much xld.