9tanstaafl9
Well-known Member
- Joined
- Mar 23, 2008
- Messages
- 535
Is there some sort of rule against having more than one On Error Goto?
I have two On Error Goto's in my macro, both of which WORK PERFECTLY if the other is commented out, but only the first works if they are not commented. I'm sure I'm missing something really basic but I can't figure it out.
In both cases, I am searching for a trigger in column F, which if found will select a range, then do my code and repeat until the search doesn't any more triggers. I probably could have found a much better way to do this, but I am not very good at coding yet, and the book VBA for dummies isn't helping.
So, if you could either tell me what's wrong with my GoTo code, OR tell me a better way to do what I want to do I would GREATLY appreciate it. I've been trying this on my own since last night.
I have two On Error Goto's in my macro, both of which WORK PERFECTLY if the other is commented out, but only the first works if they are not commented. I'm sure I'm missing something really basic but I can't figure it out.
In both cases, I am searching for a trigger in column F, which if found will select a range, then do my code and repeat until the search doesn't any more triggers. I probably could have found a much better way to do this, but I am not very good at coding yet, and the book VBA for dummies isn't helping.
So, if you could either tell me what's wrong with my GoTo code, OR tell me a better way to do what I want to do I would GREATLY appreciate it. I've been trying this on my own since last night.
Code:
'Replaces exported totals with formulas. Will temporarily screw up subtotals, but will fix later when we add real formulas for them.
Start:
Columns("f:f").Select
On Error GoTo NotDone
Selection.Find(What:="zz", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
Selection.Value = "uuu"
If Selection.Offset(2, -1) <> "" Then
Selection.Offset(1, -1).Select
Range(Selection, Selection.End(xlDown)).Select
Else: Selection.Offset(1, -1).Select
End If
For Each Cel In Selection
If Cel.Value <> "" Then Cel.Value = "Your Text" 'need to make Your Text a formula to sum the two cells to the left of each cel, figure out later
Next
GoTo Start
NotDone:
'Finds total fields in Equipment section and adds blank rows after (need for selections later)
StartA:
Columns("f:f").Select
On Error GoTo Done
Selection.Find(What:="xx", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
Selection.Value = "hhh"
Selection.Offset(1, 0).EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Done: