Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
change event question
Hi - i have the following worksheet macro.
It does 2 things 1) Makes anything typed in cell E29 into upper case 2) If a change in e29 takes place ... it changes the corresponding cells below into the proper format. The only problem is that anytime i type anywhere on the worksheet and then press enter - its bringing me to cell E29. How do eliminate that so it only has a change event when THAT cell (E29) is changed, and NOT any cell on the sheet ? Thanks scott Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False On Error GoTo ws_exit Range("f20:f20").Select Dim Rng As Range For Each Rng In Selection.Cells If Rng.HasFormula = False Then Rng.Value = UCase(Rng.Value) End If Next Rng With Target If .Column = 6 Then If ((.Row = 20 And .Row <= 20)) Then Select Case Target.Value Case "ES": FormatCells Target, "###0.00;[Red]###0.00" Case "NQ": FormatCells Target, "###0.00;[Red]###0.00" Case "ER2": FormatCells Target, "###0.00;[Red]###0.00" Case "YM": FormatCells Target, "###0;[Red]####" Case "ZB": FormatCells Target, "# ??/32;[Red]# ??/32" Case "EUR": FormatCells Target, "0.0000;[Red]0.0000" Case "JPY": FormatCells Target, "0.0000" Case "GE": FormatCells Target, "00.000;[Red]00.000" Case "CAD": FormatCells Target, "00.000;[Red]00.000" Case "YG": FormatCells Target, "###0.00;[Red]###0.00" Case "YI": FormatCells Target, "0.000;[Red]0.000" Case "SPY": FormatCells Target, "###.00" Case "QQQ": FormatCells Target, "###.00" End Select End If End If End With ws_exit: Application.EnableEvents = True End Sub Private Sub FormatCells(Rng As Range, format As String) Rng.Cells(1, 1).NumberFormat = format Rng.Cells(1, 2).NumberFormat = format Rng.Cells(1, -1).NumberFormat = format Rng.Cells(1, -2).NumberFormat = format Rng.Cells(0, 0).NumberFormat = format Rng.Cells(-0, 1).NumberFormat = format Rng.Cells(0, 2).NumberFormat = format Rng.Cells(0, 3).NumberFormat = format Rng.Cells(0, -1).NumberFormat = format Rng.Cells(0, -2).NumberFormat = format Rng.Cells(0, -3).NumberFormat = format End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Quick VBA Worksheet Change Event or Selection Question: | Excel Worksheet Functions | |||
Change minimumscale with the change event of a combobox | Excel Programming | |||
Question about an event | Excel Programming | |||
change event/after update event?? | Excel Programming | |||
Event Question | Excel Programming |