Run Macro after pasting ugly data

mdeshazo

New Member
Joined
Dec 30, 2002
Messages
17
I am working on creating a smarter form for our clients. They only have access to a webpage which I believe I can have them copy from and paste into excel. From there, after they paste, I want to run a macro that will scrape through and grab the necessary data to help them fill out their form.

I am running Excel 2007 (as are the vast majority of my users).

I have figured I either need to use worksheet_calculate() or worksheet_change. In an effort to keep it simple I am using worksheet_calculate() so that when the user pastes his/her screen scrape into the worksheet (same place every time (cell B2)), then in M1 I have the formula "=len(left(B3,7))", which should always return the value of 7.

What I am hoping to do is not only grab the proper data (pasting it to a worksheet titled "Input") from what the user pastes, but also once the macro is completed, then the macro would go to worksheet titled "Input" and delete the original worksheet the user pasted into.

Below is the code I have devised thus far (for scraping the data) and it isn't working.

Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False
Application.EnableEvents = False

Select Case Range("M1").Value
Case Is = 7
' Write Budget Number in Cell M3
Cells(3, 13).FormulaR1C1 = "=left(R3C2,7)"
Case Is <> 7
GoTo ErrHnd
End Select

ErrHnd:
Application.ScreenUpdating = True
Application.EnableEvents = True
Response = MsgBox("I didn't work :(", vbExclamation + vbOKCancel, "Dang It!")

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Any thoughs on this from anyone? I've been orking on it and getting nowhere.

Would love to hear any thoughts.

Cheers,
Michael D
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,716
Members
452,939
Latest member
WCrawford

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