Worksheet_Change - NEW to VBA

  • Thread starter Thread starter pippo00
  • Start date Start date
P

pippo00

Another user kindly provided me with the following Worksheet_Change
macro.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
Application.EnableEvents = False
If Target.Count = 1 And Target.Address = "$F$454" Then
Select Case Target.Value
Case "Growth Rate"
Range("H454:q454").NumberFormat = "0.0%"
Case "Value"
Range("H454:q454").NumberFormat = "#.#"
End Select
End If
ErrorHandler:
Application.EnableEvents = True
End Sub

I would like to use relative references, so that if I insert a row
above above F454 the Worksheet_Change macro keeps working. Can someone
help me to modify the macro?

What would be a good starting point for someone interested in applying
VBA to finance?

Thanks a lot.

PiPPo
 
Give cell F454 a name (Insert>Name>Define...), range H454:Q454. and then use
the names with

If Target.Count = 1 And Not Intersect(Target,Range("the_name")) IS
Nothing then

and


Range("other_name").NumberFormat = "0.0%"
Case "Value"
Range("other_name").NumberFormat = "#.#"

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

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

Back
Top