Hello,
I have 2 macros for 2 different situations, and what I would like to achieve is that I do not have to separately run them.
Basically incoming excels files are formatted in 2 different ways. If one of my macros fail, I use the other one.
My aim is that if the first macro returns an error message, then excel should automatically run the second macro for me.
Is this at all possible?
The two macros are as follow:
Macro1:
Macro2:
Also suggestions to optimize the existing 2 macros are very welcome
Thank You for all your input!
I have 2 macros for 2 different situations, and what I would like to achieve is that I do not have to separately run them.
Basically incoming excels files are formatted in 2 different ways. If one of my macros fail, I use the other one.
My aim is that if the first macro returns an error message, then excel should automatically run the second macro for me.
Is this at all possible?
The two macros are as follow:
Macro1:
Code:
Sub Fetch()
Dim r As Long
ActiveSheet.Range("D13:D15,D32,D44:D48,D51:D53,D70,D78,D93").Copy
With Workbooks("input.xls").Worksheets("standard")
r = .Range("D" & .Rows.Count).End(xlUp).Row
If .Range("D" & r).Value <> "" Then r = r + 1
.Range("D" & r).PasteSpecial Paste:=xlPasteValues, Transpose:=True
End With
ActiveSheet.Range("C101:C102").Copy
With Workbooks("input.xls").Worksheets("standard")
r = .Range("S" & .Rows.Count).End(xlUp).Row
If .Range("S" & r).Value <> "" Then r = r + 1
.Range("S" & r).PasteSpecial Paste:=xlPasteValues, Transpose:=True
End With
End Sub
Macro2:
Code:
Sub Fetchke()
Dim r As Long
ActiveSheet.Range("D13:D15,D32,D44:D48,D51:D53,D63,D68,D83").Copy
With Workbooks("input.xls").Worksheets("standard")
r = .Range("D" & .Rows.Count).End(xlUp).Row
If .Range("D" & r).Value <> "" Then r = r + 1
.Range("D" & r).PasteSpecial Paste:=xlPasteValues, Transpose:=True
End With
ActiveSheet.Range("C91:C92").Copy
With Workbooks("input.xls").Worksheets("standard")
r = .Range("S" & .Rows.Count).End(xlUp).Row
If .Range("S" & r).Value <> "" Then r = r + 1
.Range("S" & r).PasteSpecial Paste:=xlPasteValues, Transpose:=True
End With
End Sub
Also suggestions to optimize the existing 2 macros are very welcome
Thank You for all your input!