View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Feaver Jim Feaver is offline
external usenet poster
 
Posts: 16
Default Removing dashes in entire column using VBA

Hey 'Sup:

I followed Gord's lead and added some error trapping code.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Cleanup
Application.EnableEvents = False
If Target.Column = 11 Then
RemoveDashes
End If
Cleanup:
Application EnableEvents = True
End Sub

Sub RemoveDashes()
Dim lLastRow As Long
Dim Sh1 As Worksheet, rng As Range

Set Sh1 = ThisWorkbook.Worksheets("Sheet1")
lLastRow = Sh1.Cells(Rows.Count, "K").End(xlUp).Row
Set rng = Sh1.Range("K1", "K" & lLastRow)

rng.Replace _
What:="-", Replacement:="", _
SearchOrder:=xlByRows, MatchCase:=True

Set Sh1 = Nothing
Set rng = Nothing
End Sub

hth,
Jim Feaver


"sup191 " wrote in message
...
Thank you so much Gord and Jim!! I still getting a grasp on all this
VBA stuff and you've both given me a couple ways to achieve my goal. I
love learning this stuff...

I only hope I can understand it enough to be of some help to people in
need as both of you have been to me. ;)

Thanks again guys!
sup191


---
Message posted from http://www.ExcelForum.com/