Hi Guys,
I am facing issues while displaying data fetched from an excel table. The data is fetched dynamically through a loop and I want them to be displayed in other table in the same workbook. The code snippet is mentioned below:
Private Sub cmdExtract_Click()
Dim i, old_count As Integer
i = 0
old_count = 0
For Each chk In ActiveSheet.CheckBoxes
If chk.Value = 1 Then
myArray(i) = chk.Caption
i = i + 1
End If
Next chk
Select Case cmbDatagroups.Value
Case "Insight"
With ActiveWorkbook.Sheets
.Add after:=Worksheets(Worksheets.count)
End With
ActiveSheet.Name = "Insight_records"
insightFlag = True
For i = 0 To UBound(myArray)
strSQL = "select * from [AGE_INSIGHT$] where [Scenario ID]= '" & myArray(i) & "' "
closeRS
OpenDB
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
old_count = old_count + rs.RecordCount
ActiveCell.CopyFromRecordset rs
Next
End Sub
****************
The AGE_INSIGHT is the table from where I am fetching the data based on some Scenario ID's.
But currently only the last Scenario Id present in the recordset is getting displayed in the output. i.e say if scenario id's IN0000001 and IN000002 are selected then the data of IN000002 is only displayed in the output.
All the excel guru's out here please help.
Bookmarks