Help with On errror Goto

sebastriantran

New Member
Joined
Sep 19, 2014
Messages
31
Hi everyone,

My company is purchasing thousands of item via Paypal and I am building a macro to get data from checkout page. Normally I want to get the Funding type and Funding sources. So here is what I do:

1) Copy whole content of the checkout page (Ctrl C)
2) Paste all content into my worksheet (Ctrl V)
3) In VBA, I use Find to searh the word:

Code:
'Locate bank
On Error GoTo Creditcard
    Selection.Find(What:="Funding type: Bank Account", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Copy Range("Q" & k)


    Selection.Find(What:="Funding type: Bank Account", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Offset(1, 0).Copy Range("R" & k)


'Locate card
Creditcard:
On Error GoTo Voucher
    Selection.Find(What:="Funding type: Credit Card", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Copy Range("Q" & k)


    Selection.Find(What:="Funding type: Credit Card", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Offset(1, 0).Copy Range("R" & k)
        
'Locate voucher
Voucher:
    Selection.Find(What:="Funding type: Voucher", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Copy Range("S" & k)


    Selection.Find(What:="Funding type: Voucher", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Offset(1, 0).Copy Range("T" & k)

However it seems that my error handling does not work. What I want is to make the macro run through each case of funding: Bank account, Credit card, Voucher, Paypal balance. But when there's only Voucher, it shows run-time error '91 with lines on Credit card.

Any suggestion to my case?

Thank you very much!
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
What do you want to do when you find the funding type?

Also, where are you searching for them?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top