Access databse from excel vba tutorial
MainWorkBook.Sheets("Sheet2").Range("C" & intRowCounter).Value = resultSet.Fields("Age").Value
MainWorkBook.Sheets("Sheet2").Range("B" & intRowCounter).Value = resultSet.Fields("Name").Value MainWorkBook.Sheets("Sheet2").Range("A" & intRowCounter).Value = resultSet.Fields("Emp Id").Value Set resultSet = Connection.Execute(strQuery) StrQuery = "SELECT * FROM where Dept = ‘IT’" Set Connection = CreateObject("ADODB.Connection") MainWorkBook.Sheets("Sheet2").Range("B" & intRowCounter).Value = resultSet.Fields("Name").Value resultSet.movenext Read the data from the resultSet and display in the newly created excel and close the resultSet.StrQuery = “ SELECT * FROM where Dept = ‘IT’” Write the query for fetching the data provide the table name as the range from the “DB Data.xlsx”.Open the connection and provide the DSN name as the same name provided in step 2.(In this caseit is “SumitODBC”).Set Connection = CreateObject(“ADODB.Connection”) Open a new excel file in which you will fetch the data from “DB Data.xlsx” and Open the VB Editor.Create a button on newly created excel and assign the macro function to it.Read the data from the resultSet and display in the newly created excel and close the resultset.Execute the query and store the result in resultSet.Write the query for fetching the data, provide the table name as the range from the “ DB Data.xlsx”.Open the connection and provide the DSN name as the same name provided in step 2.(In this caseit is “ SumitODBC”).Open a new excel file in which you will fetch the data from “DB Data.xlsx”.