Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default Worksheet_Change - NEW to VBA

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

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Worksheet_Change - NEW to VBA

Give cell F454 a name (InsertNameDefine...), 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)

wrote in message
ups.com...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"