Match or not

Sully38

Board Regular
Joined
Mar 9, 2004
Messages
167
I have a table which contains 70 records with pct values they total 100%. I have another file that contains currency values. I need to run the currency file through the pct file and create 70 records multiplying the currency by the pct. There is no matching fields to hit on or match on. Is this possible within a query or does this require a program to be written. Any help is appreciated.

:confused:
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
It depends on what you need the output to look like.

Rich (BB code):
SELECT pctTable.a, *[currTable].[mycost] AS CostByItem
FROM pctTable, currTable;


Real simple SQL query where I used generic field names.
I used 3 actual dollar values to be divided into categories, and 4 categories - which produced 12 unique entries as a response, one per math calculation, which is probably not what you need.

Ordinarily I'd suggest opening two recordset objects, opening the currTable first, read the $$ value, then walk thru the entire table for the pctTable and then save the values to an array.

You could also use the above SQL, or something simlar, and walk thru the recordset once to produce an answer.

Rich (BB code):
Sub AddItUp()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL as String
Dim asnVal(4) As Single

Set dbs= CurrentDb()
strSQL = "SELECT dividebyitem.a, *[dollarcost].[mycost] AS CostByItem
FROM dividebyitem, dollarcost"
Set rs = dbs.OpenRecordset(strSQL, dbOpenSnapshot)

With rs
  Do Until rs.EOF
    ' Assumes the value of field a is numeric 1-4 for test
    ' This saves each of the $$ values next to each value to an array setup
    ' To handle up to 5 values (0-4) - am Ignoring value 0 for convenience

    asnVal(.Fields(0).Value)=asnVal(.Fields(0).Value) + .Fields(1).Value
    .MoveNext
  Loop
End With

For x = 1 to 4
  debug.print asnVal(x)
Next x

Set rs = Nothing
Set dbs = Nothing
End Sub


Mike
 
Upvote 0

Forum statistics

Threads
1,221,780
Messages
6,161,887
Members
451,730
Latest member
BudgetGirl

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