Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Tue, 15 Feb 2005 @ 00:16:39 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: Running macro from EXCEL .
From:   McCall, Glenn David

I haven't run a macro, but have run queries from VBA scripts within Excel. You will probably need to create a VBA script to run the macro.

In excel 2003 you can use VBA script such as:

     Param1 = cells (1,1)           ' Get A1 value
     Param2 = cells (1,2)           ' Get A2 value

Then run your query (search the VBA help using openDatabase and or RecordSet for some examples of how you might do this).

Then in a loop read through the data one record at a time and place them into the spreadsheet.


     With recordSet
         row = 10           ' Start in row 10
         Do While Not .EOF
                 ' assumes query returns a column called "firstColumn"
                 ' put the value in the first column of the current row
             Cells (row, 1) = !firstColumn

                 ' assumes query has a column called "col2"
                 ' put the value in the second column of the current row
                 Cells (row, 2) = !col2
             row = row + 1      ' point to the next row in the spreadsheet.
     End With

Hope this is of some help

Glenn Mc

  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023