Macro works until I create a new macro, then when run original macro excel runs new macro instead

carter93chen

New Member
Joined
Jun 19, 2014
Messages
3
Hi there,

I am in charge of aggregating a lot of information into a document every week for my job, and I decided to create a series of macros to automate most of the process.

The first macro I created goes as follows: open a window in chrome, go the company website, scroll down, copy some data from the page, and paste into excel. When I run the macro after I write it, it works perfectly.

Now, I create the second macro. It goes through pretty much the same process, but copies a different block of data from the website.

After creating the second macro, I tried to run the first macro--and it returned the results from the SECOND macro instead. The results are identical to the ones achieved by running the second macro.

This is my first experience with excel macros so I may be missing something very novice and obvious. Any help is appreciated.

Thanks,
Carter
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
We will probably need to see something about your code or we will be grasping at straws all the while. We will probably need to know some oft he following answers as well. How are the codes being started, buttons other methods? Where is your code located in a workbook, add-in or personal? Just to name a few
 
Upvote 0
carter93chen,

Welcome to the MrExcel forum.

1. What version of Excel and Windows are you using?

2. Are you using a PC or a Mac?



In order to assist you it would help us if you posted the two macro codes using code tags.

When posting VBA code, please use Code Tags - like this:

[code=rich]

'Paste your code here.

[/code]
 
Upvote 0
Hi guys,

Thanks for replying.

To answer y'all's questions:

I am starting the code with buttons... I think. I click record macro, then go through the motions. When I am done I click 'stop recording.'
I usually save my macros in the 'This Workbook' option.
I am using Excel 2010 on Windows 7

This is the code for the first macro, BEFORE I create the second macro:

Code:
Sub Macro2()
'
' Macro2 Macro
'
'
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
Range("A10").Select
End Sub

And here is the macro AFTER creating the second macro; both codes are displayed:

Code:
Sub Macro2()
'
' Macro2 Macro
'
'
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
Range("A10").Select
End Sub
Sub Macro4()
'
' Macro4 Macro
'
'
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
End Sub

To reiterate, running the first macro (macro 2) after creating the second macro (macro 4), returns the results of running the second macro (macro 4).

Thanks,
Carter
 
Upvote 0
If all your macros are doing is pasting from the clipboard you need to make sure that what's on the clipboard is what you want to paste before running them.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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