Code Help

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!!
 
R

Ron de Bruin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top