Code Help

  • Thread starter Thread starter RealEstate
  • Start date Start date
R

RealEstate

hi guys, i have a vb question. i have the following code:

____________________________________________________
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("B6")) Is Nothing Then Exit Sub

If (Target.Value) = "Rental" Then
Range("F6").NumberFormat = "$#,##"
Else
Range("F6").NumberFormat = "0.0%"
End If

End Sub
------------------------------------------------------------------------------------

how do i make it so that if b6 changes, then f6 will change. if b7
changes, then f7 will change. if b8 changes, then f8 will change, and
so on...

any help would be greatly appreciated. thanks!!
 
Try this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("B6:b100")) Is Nothing Then Exit Sub
If (Target.Value) = "Rental" Then
Target.Offset(0, 4).NumberFormat = "$#,##"
Else
Target.Offset(0, 4).NumberFormat = "0.0%"
End If
End Sub
 
Back
Top