Possible or Impossible excel question w/macro

juvio

New Member
Joined
Dec 2, 2002
Messages
4
Here's the scenario.
I have a list of about 70-80 different investment funds located in column A. Column B is empty. Column C will have some 15 or so investment funds, all of which will also be located in column A. the column next to Column C will have a dollar amount that corresponds to the investment account name in column c. Additional columns to the right of column c will demonstrate the same concept, just additional fund names with investment amounts. The objective was to set up a macro that by using the search and find functions, of the edit menu would allow me to search column c for each of the names of the funds located in column a. When one of the funds was not found, then skip that and go to trying to find the next fund. Then move the amount column and copy that value to the clipboard. then move to column a and do the same search and find function thereby finding the named fund, move the curso to column b and paste the value into that location.

If anyone can get back to me on this, I would really appreciate it.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
It's a LOT easier if you could put all the source fund names in one column - say C, and values in D. IS that a possibility?

Do I get you right: you will select a portfolio for study in column A, and the rest of the sheet provides reference data listing all the funds you know and their current(?) value / what you have invested in them / whatever. You then want to run the macro and it will hunt through the reference material and assign values from it to the corresponding funds in A. These values will go into B.

If you do have to use several columns for reference, so long as there are no duplicate values you could use a simple but ugly series of SUMIF formulae:

in cell B3:

=SUMIF(C1:C100,A3,D1:D100)+SUMIF(E1:E100,A3,F1:F100)+.....etc

Z
 
Upvote 0
You need to run a double loop

eg

Sub DATALOOP()

Application.ScreenUpdating = False

DATA = Range("A1:A200")
CROW = 1

For Each LDATA In DATA

If LDATA = "" Then Exit For

Data2 = Range("C1:C50")
CROW2 = 1

For Each LDATA2 In Data2

If LDATA <> LDATA2 Then
CROW2 = CROW2 + 1
GoTo 100
End If

If LDATA = LDATA2 Then Range("B" & CROW) = Range("D" & CROW2)

100

Next LDATA2

CROW = CROW + 1

Next LDATA

Application.ScreenUpdating = True

End Sub


That should do the trick.

Luke
 
Upvote 0
I agree too, but for this to work comprehensively you need to have all your reference funds in Column C and all the values in D - like I first suggested. I read your original to mean you would have references in C1:D15 & E1:F15 & G1:H15 etc. You'll need a third loop in the code offered to calculate all this.

Z
 
Upvote 0
Didn't see that - easiest thing as someone suggested would be to simply copy and paste data from E&F, G&H to the next blank cell in C etc... this can be automated at the beginning of the macro (though you may need to adjust the range of Data2)

i.e

Range("E1:F15").Copy
Range("C16").PasteSpecial xlPasteValues

Range("G1:H15").Copy
Range("C31").PasteSpecial xlPasteValues

then remainder of code.
 
Upvote 0
yep...but i still think, the safest way is to copy and paste the data manually :biggrin:. ( depending on the number of columns
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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