Joining Two Macros

zealot777

Board Regular
Joined
Nov 9, 2006
Messages
135
Hi!

I need your help in combining two macros. Both of them are fully-functional and complete – except for the fact that each of them is performing only a half of the full intended procedure. Let me briefly describe the macros:

Workbook: STATS.xls
MACRO: PrepareXY

The macro basically takes each pair of X,Y values from the N,O columns, pastes them into the controlling cells K3,L3 and then copies the resultant statistics to a separate tab DataXY for each pair of X,Y

Workbook: Mining_Data2.xls
Macro: Extract_Data

This macro extracts records from the A to E columns at the Raw tab based on a condition that the value of the Output is greater than 970 – and then pastes these records to a separate tab EXTRACT.

Now I need to combine these macros in such a way that the resultant macro works on the third workbook, REF2.xls (which has very similar structure). The resultant macro would work as follows:

The PrepareXY part of this macro would take the letter pairs from the M,N column on the results tab and paste them into the controlling cells I2,J2. After each letter-pair paste operation the Extract_Data part of this macro would scan the Rank column to select only records bigger than 0 and then would copy all corresponding rows of records from D to J columns for each such row to output tab.

I hope I am not asking too much))

Will be looking forward to any feedback!

Dima

The link to the archive:

http://rapidshare.com/files/124988650/COMBINE.zip.html (Please select "Free" download)
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

iliace

Well-known Member
Joined
Jan 15, 2008
Messages
3,546
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
I think I was able to get it to do what you want, from STATS.xls, using this:

Code:
Public Sub CombineMacros()
  Dim xl As Excel.Application
  Dim wkb As Excel.Workbook
  
  Call PrepareXY
  
  Set xl = New Excel.Application
  Set wkb = xl.Workbooks.Open(ThisWorkbook.Path & _
        IIf(Right$(ThisWorkbook.Path, 1) <> Application.PathSeparator, _
                  Application.PathSeparator, "") & _
                              "Mining_Data2.xls")
  
  wkb.Application.Run "Extract_Data()"
  xl.Visible = True
End Sub

See if it works for you.
 
Upvote 0

Forum statistics

Threads
1,191,166
Messages
5,985,051
Members
439,935
Latest member
Monty238

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
Top