Parameterization Required for this macro

sathyaanil37

New Member
Joined
Sep 14, 2012
Messages
32
Hi Team,

Actually I gone through the below code it is working file,It will connect to database and retrieve table results in sheet.
Here we are providing table name in Sqlquery so it is picking only that table details(table1)
Instead of that using the same code it will take table names that is present in sheet1 from A1 to A6 and give the results of those tables data in another sheet.
Code:
 Dim strSQL As String
 Dim strResult As String
 Dim OraDynaSet As Object
 Dim i As Integer
 Worksheets.Add
 strScript = "select tablenames, OWNER from ALLTABLES  group by tablenames where tablenames in('table1')

  Set OraDynaSet = objDataBase.DBCreateDynaset(Script, 0&) 

 If OraDynaSet.RecordCount > 0 then
        OraDynaSet.MoveFirst
        For i = 1 to OraDynaSet.RecordCount
                ActiveSheet.Cells(i,1) = OraDynaSet.Fields(0).Value 
        ActiveSheet.Cells(i,2) = OraDynaSet.Fields(1).Value
        OraDynaSet.MoveNext
    Next i
 End if
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Watch MrExcel Video

Forum statistics

Threads
1,108,501
Messages
5,523,293
Members
409,508
Latest member
Afc

This Week's Hot Topics

Top