I am working on below table and with help of Excel VBA - Dictionary - I am trying to capture all the details - 1) First step is to search in "Results Out" Column - if the value is "No" - then we need to read all the values with their appropriate header. 2) So for 2nd record - i.e., Name = XYZ - we need to store all the details. Based on No. of Subjects column - we need to store value of all the subjects and their corresponding marks - will be used for further calculation and generate the "Result" column.
I got it partially working - like I am able to capture details - but not able to store details of all the subject and their marks:
Sr. No. Results Out? Result Name Age No. of Subjects Subject Names Marks
1 Yes Pass ABC 21 3 Maths 10
Science 26
History 34
2 No XYZ 10 2 Maths 24
Science 36
Below is the code that I have used that is partially working:
Public Sub test_dict()
Dim dict As New Scripting.dictionary
Set dict = New dictionary
sSheetIndex = 1
intTargetRow = 2
Set objUsedRange = Worksheets.Item(3).UsedRange
For Iter = 1 To objUsedRange.Columns.Count
sCellName = objUsedRange.Cells(1, Iter)
sCellValue = objUsedRange.Cells(intTargetRow, Iter)
dict.Item(sCellName) = sCellValue
Next
For i = 0 To dict.Count - 1
s = dict.Items()(i)
Debug.Print dict.Keys()(i) & " " & dict.Items()(i)
Debug.Print s
Next i
End Sub