How to extrapolate a 2 variable combination from scripting.dictionary

A380038

New Member
Joined
Nov 23, 2011
Messages
12
I am trying to leverage code written by programmer that is far beyond my own ability. The objective of this routine is to determine whether a balance exists in two variable combination(Fund and SRC).
The fund and source is determined from a loop on wksProcessData.

wksprocessdata example:
<TABLE style="WIDTH: 245pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=325 x:str><COLGROUP><COL style="WIDTH: 52pt; mso-width-source: userset; mso-width-alt: 2523" width=69><COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 3072" width=84><COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 3072" width=84><COL style="WIDTH: 35pt; mso-width-source: userset; mso-width-alt: 1682" width=46><COL style="WIDTH: 32pt; mso-width-source: userset; mso-width-alt: 1536" width=42><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: yellow; WIDTH: 52pt; HEIGHT: 12.75pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl32 height=17 width=69>PLAN</TD><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext; BACKGROUND-COLOR: yellow; WIDTH: 63pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl28 width=84>SSN</TD><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext; BACKGROUND-COLOR: yellow; WIDTH: 63pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl27 width=84>DATE</TD><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext; BACKGROUND-COLOR: yellow; WIDTH: 35pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl24 width=46>FUND</TD><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext; BACKGROUND-COLOR: yellow; WIDTH: 32pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl25 width=42>SRC</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; HEIGHT: 12.75pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl29 height=17 x:num>11111</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl30>999-99-9999</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl31></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl33>BLNK</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl34 align=right x:num="1">01</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; HEIGHT: 12.75pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl29 height=17 x:num>22222</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl30>987-65-4321</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl31></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8">BLNK</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: transparent; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl26 align=right x:num="2">02</TD></TR></TBODY></TABLE>

Pull_Balances is a dictionary that lists all possible fund and src combinations for the plan/ssn combo.

Public Sub Verify_FndSrc()
'Balance return value and counter for Next loop
Dim f_bal_tmp As ClsStoragePlace
Dim BCount As Long
'Balance Subtotals by Fund and Source
Dim SrcFund_Total As ClsStoragePlace
Dim Total As Double
Dim srng As Excel.Range
Dim scell As Excel.Range
Dim PlanN As String
Dim ssn1 As String

'If Not DEBUGMODE Then On Error GoTo ErrorHandler
With wksProcessData
Set srng = Range(.Range("A2"), .Range("A65536").End(xlUp))
End With
For Each scell In srng
'create dictionary to list balances for all funds and sources
PlanN = scell
ssn1 = scell.Offset(0, 1)
Set f_bal_tmp = ModCRRFPRS.Pull_Balances(PlanN, ReturnSSN(Trim(ssn1)))
Set SrcFund_Total = New ClsStoragePlace
For BCount = 0 To f_bal_tmp.Item_Count - 1

'Total by source/Fund
If SrcFund_Total.Item_Exist(Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Key_ByIndex(BCount), 4)), _
"00") & "|" & Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Key_ByIndex(BCount), 3)), _
"0000")) Then

SrcFund_Total.Add_To_Number(Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Key_ByIndex(BCount), 4)), _
"00") & "|" & Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Key_ByIndex(BCount), 3)), _
"0000")) = Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Item_ByIndex(BCount), 4)), _
"###0.00")
Else
SrcFund_Total.Set_Item(Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Key_ByIndex(BCount), 4)), _
"00") & "|" & Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Key_ByIndex(BCount), 3)), _
"0000")) = Format(Trim(ModPublic.Pull_From_String(f_bal_tmp.Item_ByIndex(BCount), 4)), _
"###0.00")
End If

'need the total for fund/src combo for the current line on wksprocessdata
Total = :confused:

Next
If Not Total = 0 Then
scell.Offset(0, 3).Interior.ColorIndex = 36
scell.Offset(0, 3).AddComment "NO BLNK BALANCE FOR SPECIFIED SOURCE"
End If
Next

End Sub

I apologize if this is confusing. I'm teaching myself VBA on the job.
 

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