Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
modify a macro to apply to a specific range of cells
How would I modify the following code to only apply to a range, say A1:A10?
Private Sub Worksheet_Change(ByVal Target As Range) Dim iPos As Long On Error GoTo ws_exit: Application.EnableEvents = False With Target If .Column = 1 Then iPos = InStr(1, Target.Value, " ") If iPos 0 Then .Value = Right(.Value, Len(.Value) - iPos) & _ " " & Left(.Value, iPos - 1) End If End If End With ws_exit: Application.EnableEvents = True End Sub (Code retrieved from: http://groups.google.com/group/micro...701548d16353f8 ) Thanks! Dave -- A hint to posters: Specific, detailed questions are more likely to be answered than questions that provide no detail about your problem. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
modify a macro to apply to a specific range of cells
I presume you mean that you only want it to run if any of those cells are
changed Try this: IF not intersect(target,range("A1:A10")) is nothing then 'put your code here end if "Dave F" wrote: How would I modify the following code to only apply to a range, say A1:A10? Private Sub Worksheet_Change(ByVal Target As Range) Dim iPos As Long On Error GoTo ws_exit: Application.EnableEvents = False With Target If .Column = 1 Then iPos = InStr(1, Target.Value, " ") If iPos 0 Then .Value = Right(.Value, Len(.Value) - iPos) & _ " " & Left(.Value, iPos - 1) End If End If End With ws_exit: Application.EnableEvents = True End Sub (Code retrieved from: http://groups.google.com/group/micro...701548d16353f8 ) Thanks! Dave -- A hint to posters: Specific, detailed questions are more likely to be answered than questions that provide no detail about your problem. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
modify a macro to apply to a specific range of cells
Perfect, thanks.
Dave -- A hint to posters: Specific, detailed questions are more likely to be answered than questions that provide no detail about your problem. "Barb Reinhardt" wrote: I presume you mean that you only want it to run if any of those cells are changed Try this: IF not intersect(target,range("A1:A10")) is nothing then 'put your code here end if "Dave F" wrote: How would I modify the following code to only apply to a range, say A1:A10? Private Sub Worksheet_Change(ByVal Target As Range) Dim iPos As Long On Error GoTo ws_exit: Application.EnableEvents = False With Target If .Column = 1 Then iPos = InStr(1, Target.Value, " ") If iPos 0 Then .Value = Right(.Value, Len(.Value) - iPos) & _ " " & Left(.Value, iPos - 1) End If End If End With ws_exit: Application.EnableEvents = True End Sub (Code retrieved from: http://groups.google.com/group/micro...701548d16353f8 ) Thanks! Dave -- A hint to posters: Specific, detailed questions are more likely to be answered than questions that provide no detail about your problem. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need help - Macro to copy a specific range | Excel Worksheet Functions | |||
How do i a apply range(autoformat) in non-adjacent cells? | New Users to Excel | |||
How to apply rounding across a range of cells with other formulae | Excel Worksheet Functions | |||
How can I apply the ROUND function to a range of cells in a workbo | Excel Discussion (Misc queries) | |||
How do I modify range of cells viewed in HTML format? | Excel Discussion (Misc queries) |