ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error handling - dodgy syntax (https://www.excelbanter.com/excel-programming/379924-re-error-handling-dodgy-syntax.html)

[email protected]

error handling - dodgy syntax
 
Hi Helen,

Yeah the resume would resume at the line that created the error which
you have already cleared.

Change your error handling to:

ChangeNotNecessary:
If Err.Number = 1004 Then
Resume Nextx

else
Msgbox Err.number & " " & Err.Description
End If

Nextx:
Next x


Any problems then post back,

James

Helen wrote:
I've created the following code, but it will only run once before sticking,
I've included Resume, but I'm not sure I've put it in the right place. After
the error has been identified I want the macro to move on to Next X.

For x = 4 To myRows
NewFormat = Range("G" & x)

On Error GoTo ChangeNotNecessary

If WorksheetFunction.Search(",", NewFormat, 1) + 2 = Len(NewFormat) Then

Range("G" & x).Select

Selection.Replace What:=".", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:=",", Replacement:=".", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Style = "Comma"

End If

ChangeNotNecessary:
If Err.Number = 1004 Then
Err.Clear
End If
On Error GoTo 0
Resume

Next x




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com