Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




VBA And Excel : Import Data From Another Workbook


Hello,

I have data in different workbooks. The Question :
I want with VBA import the data from these workbooks to the specified workbook.
P.E. I have a workbook named PeriodTotal. From 13 workbooks named Period1 until Period13 I want to import the data from these 13 workbooks. First the data from Period1, after these data he must insert the data from Period 2, etc.

Who can help to solve this problem.

Thanks on advance.

Benny




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Import Data From Another Excel Workbook : VBA
Dear Friends

I want to know how can I import data from another workbook?
The below code is for the workbook named school
Code:
With Worksheets("class7").Cells(rwIndex, 1)
                ctd = .Value
                If ctd = td Then
                    Range("F8").Value = Worksheets("class7").Range("H" & rwIndex)
            


I have another workbook named teacher from where i want
import teacher names with some processing like above.....
Actually I dont know what to provide as a parameter to the
Worksheets object...

Please help me
Thanks in advance
JohnBEST

Import Data In Excel From Other Workbook
Hallo,

I try to import data from different workbooks in one workbook.
In PeriodTotal I want to import the data came from the workbooks in Period1, Period2 from Period1. The data from Period2 must put direct after the data from Period1. This is an simple example, normally I must make it with 13 to 52 Workbooks.

Please, who can solve my problem???

See attachment

Thanks on advance

Benny

Import Excel Workbook Into An Open Worksheet
Dear people,

I'm trying to explain what must happened. I have an open spreadsheet(workbook), i need some values from another spreadsheet. Earlier i had implement a script to import a textfile, but now i must import a spreadsheet. The issue is that i must set the values into the correct cells. For examle: I need a button to import the spreadsheet. In this "closed" spreadsheet, i must take the range from c6 till the end and want to import this values into my "open" workbook from cell c6 till the end. I hope this is possible, could somebody help me with this problem. This is the code to import a text file into a worksheet, but now i must import values from an excel workbook into my worksheet. When we import this must not count but import the values into 1(name = worksheet1) worksheet, i hope you can understand my situation.

Sub ImportTextfile()



Dim wbk As Workbook, sFileName, wks As Worksheet
Set wbk = ActiveWorkbook
Set wks = ActiveSheet
Workbooks.OpenText _
Filename:=wbk.Path & " extfile.txt", _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=False, _
Semicolon:=False, _
COMMA:=False, _
Space:=False, _
Other:=True, _
OtherChar:="|", _
FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2))

ActiveSheet.Move _
After:=wbk.Sheets(wbk.Sheets.Count)

Set wksValidate = ActiveSheet
wks.Activate
Set wks = Nothing
Set wbk = Nothing
End Sub



Greetings,

Furkan

Import Excel Workbook Into An Open Worksheet
Dear people,

I'm trying to explain what must happened. I have an open spreadsheet(workbook), i need some values from another spreadsheet. Earlier i had implement a script to import a textfile, but now i must import a spreadsheet. The issue is that i must set the values into the correct cells. For examle: I need a button to import the spreadsheet. In this "closed" spreadsheet, i must take the range from c6 till the end and want to import this values into my "open" workbook from cell c6 till the end. I hope this is possible, could somebody help me with this problem. This is the code to import a text file into a worksheet, but now i must import values from an excel workbook into my worksheet. When we import this must not count but import the values into 1(name = worksheet1) worksheet, i hope you can understand my situation.

Sub ImportTextfile()



Dim wbk As Workbook, sFileName, wks As Worksheet
Set wbk = ActiveWorkbook
Set wks = ActiveSheet
Workbooks.OpenText _
Filename:=wbk.Path & " extfile.txt", _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=False, _
Semicolon:=False, _
COMMA:=False, _
Space:=False, _
Other:=True, _
OtherChar:="|", _
FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2))

ActiveSheet.Move _
After:=wbk.Sheets(wbk.Sheets.Count)

Set wksValidate = ActiveSheet
wks.Activate
Set wks = Nothing
Set wbk = Nothing
End Sub



Greetings,

Furkan

Import Excel Userform, Sheet2.cls, Workbook.cls To Word?
Hi,
Question:

I found a code for my Word-form.
Its making numbers for invoices. I want to use it! (verry bad)

But when I use the, import and exportmethode, it won't work. I never use Excel VBA. So my question is: Is it possible this way?

thanx

Fill A Vba Form With Excel Workbook Data, Updating The Same Workbook W/ Data From The Form
Okay I have a basic to intermediate understanding on using vba and Excel utilities. I need help with the workflow of my application rather than specific procedures.
I've got data on only one worksheet where each record is defined by an account id. Every cell on each record is populating a specific textbox on a form. The form is a basic interface for users, moving from one record to next. So mostly the data will flow from the worksheet to the form with the exception of one field for each record. The user will update that field as needed on the form. There are only 30 records or so on the worksheet. I can't rationalize learning Access and/or some database connection since there are only a few records and few fields.

This is an example of the field headers and one record:
Account Id, Account Name, Total Balance, Past Due Balance, Status
011,ChevyChaseAccount,$1200,$100,Customer sent in check (not posted).

I can think of only one way to update the form with the data and that is piece by piece:
Code:Private Sub UserForm_Initialize()
    With frmDetail
        '.txtAccountName = ActiveSheet.ActiveCell.Offset(0, 2).Value (this gives me an error since I can't use the offset property for the code in forms)
        .txtAccountName = ActiveSheet.Range("B2").Value (since I can't use offset then I have to resort in a specific address)
        .txtAccountId = ActiveSheet.Range("C2").Value (since I can't use offset then I have to resort in a specific address)
        .txtTotalBalance = ActiveSheet.Range("D2").Value (since I can't use offset then I have to resort in a specific address)
    End With
End Sub

I haven't thought of a way to move from one record to another let alone how to update that one field to another.
Let me know if you have any questions,

How To Import Excel Data From A Closed Excel File To Access Table?
Hi friends,
i have the following Excel sheet

     A B
1 BILL PAID
2 CM20 650.00
3 CM32 1750.12


 I want to import the same data into an Access table with the same field name.

Any help?

Thankx and regards

Haris


_____________________________________________________________________


Edited by - harisraz on 6/18/2006 1:33:00 AM

Copy Excel Data To New Excel Workbook HELP!
I have a excel workbook with thousands of peoples names and info. A persons record can be in the workbook more than once. I want to create a macro or somthing in excel to copy all of the same people with the last name Smith for example to a new workbook. How do I go about doing this, anyone with example code or help.

Thanks

Importing Data From Another Excel Workbook
Hello

I have thoroughly researched this topic within the forum and not really found the answer.

All I want to do is copy a range of text-only data from one sheet in a particular workbook and then paste that data into three worksheets in my current workbook. I know the VBA methods of importing data can be quite tricky so I am looking for a simple way of doing it.

Can anyone help me?

Writing Data To Another Excel Workbook
OK I got most of this done but having trouble with one piece of the puzzle... I have a button in an Excel sheet when clicked it strips data from the excel sheet into a collection. I then create another workbook.... but my trouble is writing the data to the new workbook, i'm stuck... maybe it's late or i'm just missing something.... i have the new workbook open... i didn't use Access because it is a small amount of data so it was easy to dump into a collection. Any help or pointers would be appreciated... So i'm in a macro of one workbook looking to write to a sheet in another workbook????

I using excel 2000
VB6

Vin

How Do I Use Vba To Import Excel Data????
Hello,
I am new to vba, especially word, so bear with me. I want to know how to open an excel workbook and copy the data in a worksheet to my active document using VBA. Can someone help or give me links to try?
Thanks

Excel Data Import
I am creating an Excel application that imports data exported from another application. I would like to allow users to select their name, which would define the location of their data. For instance, how can I use a variable in place of the absolute path (see partial code below) within the connection definition?


Code:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;F:Axys_oldUSERSmikeassetcat.txt", Destination:=Range("A1"))
Thank you very much for your help.

Import Excel Data
Anyone got some advice or sample code so when a user clicks on IMPORT, it will ask them the location of an excel file (which will always have the same structure) then take that file and create an access table and import all the data ?

Import Data In Excel
Hello,

The command button I click on allows me to copy or import my data into a spread sheet in Excel.

I only know how to do this however for only a line (See example below). What I do not know is what line of code to write to import my data for a new date to the next line.

Example:

Date: B1 B2
26/06/2007 1 2
? ? ?

Literally, i am only able to import or copy a line and then I am blocked.

I would appreciate if you could explain how to do this.

Note: I am using visual basic 6 from my own computer.

Thanks

Bruno.

How To Import Excel Data
Hi

I need to import data from an excel spreadsheet. I have no idea how to do this. I need to import the data into a vb app where I will validate it before saving it. Can anyone tell me how this is done?

Thanking you in advance
PORRASTAR

Import Data From Excel
Dear Friends,

Hi,

I need to Import Data from Excel into Access database. The answer would be in the way that if the data already in access database leave these records to import and only New updated records would be import in the access database from Excel Sheet.

Thanks

Syed Haider Ali

Import Data From Excel To Vb
import data from excel to vb ...?

Data Import From Excel
I am importing data from an Excel file into Access 97 Database using visual basic code. I am using Workbook.Worksheet object and looping through the cells for picking up the data.

This code is working fine on Windows 95 and Windows NT machines having 64 mb of Ram but the code gets hangged up on Windows 98 machine having 128 mb of ram and better processing power. Every time the code gets hangged up after importing about 1000 records.

Please Provide me with the solution.

Thanking You

Access Data Export To Excel Workbook
Hi,

I have created a code that exports the results of an Access query to an Excel sheet. When more queries are entered, they will be placed in the workbook as different sheets.

The problem is that while the code is running, and in the meanwhile I perform some other actions in other Excel workbooks, it sometimes happens a by code created sheet is inserted in another workbook then the one created by the code. I don't really know why and when (which other Excel actions) this happens.

How to solve this?

This is the code, thanks:

========================

Option Compare Database

Public Function OpenInExcel(queryName As String, excelName As String, Optional param As String = "", Optional sheetName As String = "Data") As Object
'On Error GoTo errorHandler
Dim xl As Object
Dim wb As Object
Dim ws As Object
Dim rng As Object
Dim rs As Object
Dim cmd As ADODB.Command

Set xl = CreateObject("Excel.Application")
xl.Caption = excelName
xl.Visible = False
Set wb = xl.workbooks.Add

wb.sheets(3).Delete
wb.sheets(2).Delete

addToExcel queryName, xl, param, sheetName
wb.sheets(1).Delete

xl.UserControl = True
xl.Visible = True

Set OpenInExcel = xl

Exit Function

errorhandler:
MsgBox Err.Description, vbCritical, "Fout " & Err.Number
End Function

===============================================

Public Function addToExcel(queryName As String, xl As Object, Optional param As String = "", Optional sheetName As String = "")
Dim wb As Object
Dim ws As Object
Dim rng As Object
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command

xl.Visible = False
xl.UserControl = False

If param = "" Then
Set cmd = New Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "SELECT * FROM [" & queryName & "]"
Set rs = cmd.Execute()
Else
Set cmd = New Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "SELECT * FROM [" & queryName & "]"
Set rs = cmd.Execute(Parameters:=Array(param))
End If

If rs.CursorType <> CursorTypeEnum.adOpenForwardOnly Then
rs.MoveLast
If rs.RecordCount > 3000 Then
If MsgBox("Er worden " & rs.RecordCount & " rijen geŽxporteerd. Dit kan enkele momenten in beslag nemen." & vbNewLine & vbNewLine & "Wilt u doorgaan?", vbYesNo + vbExclamation, excelName) = vbNo Then
Exit Function
End If
End If
rs.MoveFirst
End If

Set wb = xl.activeworkbook
Set ws = wb.worksheets.Add(after:=wb.activeSheet)
If sheetName <> "" Then ws.name = Left(sheetName, 31)

For t = 0 To rs.Fields.Count - 1
ws.Cells(1, t + 1) = rs.Fields(t).name
Next

rij = 1
While Not rs.EOF
For kolom = 0 To rs.Fields.Count - 1
With rs.Fields(kolom)
If .Type = adBigInt Or .Type = adDecimal Or .Type = adDouble Or .Type = adInteger Or _
.Type = adNumeric Or .Type = adSingle Or .Type = adSmallInt Or _
.Type = adTinyInt Or .Type = adUnsignedBigInt Or .Type = adUnsignedInt Or _
.Type = adUnsignedSmallInt Or .Type = adUnsignedTinyInt Or .Type = adVarNumeric Then

' dan is het een getal
ws.Cells(rij + 1, kolom + 1) = .value
Else
' alles anders dan een getal doen we een apostrophe voor
' dit zorgt ervoor dat alles netjes wordt weergeven
ws.Cells(rij + 1, kolom + 1) = "'" & .value
End If
End With
Next
rs.MoveNext
rij = rij + 1
Wend

ws.Rows(1).AutoFilter
ws.Range(ws.Cells(1, 1), ws.Cells(1, rs.Fields.Count)).Font.Bold = True
ws.Range(ws.Cells(1, 1), ws.Cells(rij, rs.Fields.Count)).Columns.AutoFit
ws.Range(ws.Cells(1, 1), ws.Cells(rij, rs.Fields.Count)).Rows.RowHeight = 12.75

xl.UserControl = True
xl.Visible = True

rs.Close
Exit Function

End Function

Detecting Last Data Row In Excel.Workbook Object
I am reading in data from an Excel Workbook into an Access Database in Access.

How can I detect what is the last filled row of the Spreadsheet?

For example if the spreadsheet only has two rows populated, how can I stop the code from running down all 65000 rows?

Excel VBA: Writing Data To A CLOSED WORKBOOK [Without Using ADO]
Quote: Objective:
Is there a way to write data to a CLOSED workbook without using ADO and without actually opening the destination workbook?

I am not sure whether this is possible. I want to write data from an opened workbook (Workbook A) to one which is closed (Workbook B) using Excel VBA.

Both workbooks have a common table and whenever changes are made to the table in Workbook A, those changes also need to be sent across to the table in Workbook B. Both tables have a common structure.

I was experimenting with VBA and wrote some codes that can read data from a closed workbook without using ADO.

Here is a sample of the code:


Code:

Private Sub GetData()
Dim theActiveSheet As Worksheet
Dim directory As String
Dim fileName As String
Dim sheetName As String
Dim cellRange As String

directory = "H:"
fileName = "TestFile.xls"
sheetName = "Dummy"
cellRange = "A1:C24"

Set theActiveSheet = ActiveWorkbook.Worksheets(sheetName)

With theActiveSheet.Range(cellRange)
.FormulaArray = "='" & directory & _
"[" & fileName & "]" _
& sheetName & "'!" & _
cellRange
.Value = .Value
End With
End Sub

Export Vb Program Data To A Specified Excel Workbook
Please can someone help me?

I have a vb program with user forms. The data entry is via textboxes. How do I export the data to cells in a specific excel workbook? The user will not see the excel workbook at any time. There will be a "Print" command button on the user form which will print out the excel sheet.

I have come across plenty of examples of opening a new workbook/sheet but cannot find and example of opening a workbook/sheet with a specific path. There are 7 sheets in the workbook.

Thank you.

Import Data Into VB6 Class From Excel
I have to import rows of data from an Excel workbook into my VB6 application.
I have created a class called "Institute" and defined "School" as a member of this class.
Each school has 12 properties:- .Name .Street .POBox .District .Town etc. The Excel worksheet's feilds match these properties; each row is a school.
How do I axtract the rows of data from the worksheet "T_Schools" to be schools in the class of Intitutes?

Import Data From Excel To Access Using VB
Hi...

i don't know how to import the data from excel to existing table in access by using VB. anyone can help me !!!

thanx

Import External Data In Excel
i would like to import external data to excel, but i facing a problem which is if the colulmns involve "--- Test " that will display as "#NAME?" in excel column. how can solve for this problem? that is possible to solve??

test.txt
-------
[---- Test ----]

that will separate to 3 columns. which is
column 1 = " [--"
column 2 = " -- Test"
column 3 = " ----]"

that is no problem to display column 1 and 3 but column 2 will display as "#NAME?" how can i control it by coding??

Import Data From Excel To Access
Hello !
I could use some help here! I need to import data from an excel file to an access database. I have no ideea how to do this. Can anybody help me? Thanks a lot!

Import Data From EXCEL Do ACSESS Using VB
Maybe someone can help me how i can import data from excel files from VB appl to MS Accs.

How To Import Data From Excel To MSSQLServer Using DTS ?
I'm trying to import data from Excel workbook into MSSQL Server.
But after execute the DTS.package object, I've got this error message

GenericDTS.Import.Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
The code that I use to import data is build as an DLL and run on
the IIS server.

Connection to SQLServer is "SQLOLEDB"
and to Excel is "Microsoft.JET.OLEDB.4.0" with
ConnectionProperties("Extended Properties")="Excel 8.0;HDR=YES"

The task that I belive the cause of error is defined like this

Set oCustomTask2 = oTask.CustomTask
With oCustomTask2
.Name = strName
strTemp = "Name=" & strName
.Description = strName
.SourceConnectionID = CLng(strConnID(0))
.SourceSQLStatement = strSQLStatment
.DestinationConnectionID = CLng(strConnID(1))
Select Case UCase(strDirection)
Case "IMPORT"
.DestinationObjectName = "[tmpTbl]"
Case "EXPORT"
.DestinationObjectName = "Results"
End Select
.ProgressRowCount = 1000
.MaximumErrorCount = 0
.FetchBufferSize = 1
.UseFastLoad = True
.InsertCommitSize = 0
.ExceptionFileColumnDelimiter = "|"
.ExceptionFileRowDelimiter = vbCrLf
.AllowIdentityInserts = False
.FirstRow = 0
.LastRow = 0
.FastLoadOptions = 2
.ExceptionFileOptions = 1
.DataPumpOptions = 0
End With

There're still more code thai I don't understand. If there're something
you think that it might cause this error please suggest.

Import Data From Excel To Access Db With Vb6
Can you Import data directly from an .xls file to an access database with vb6?

noccy

VB Application To Import Excel Data Into SQL?
I am just looking to see if anyone here has a VB application that can import data into SQL from .xls,.csv,.mdb

Rather than rewriting one I would like to just piggy back. I just need a single import.

How Can I Import Data From Excel To Sqlserver
hello frnd,

i have a Excel file with data and i want to import that excel file in MSSqlServer using vb6.0,

how can i do that....please help

if any one have code then please give me...

any helpful link ????


thankx in advance
regards,
koolprasad2003

Problem On Import EXCEL Data?
Hi,

Try to import the data from EXCEL and everything perfect except the vb6 ignore any cell that contain the character '

First, I thought is the french character problem, but it did accept other french characters. I try to re-enter the cell manually without the '

The import run OK then I put the ' on the other cell and the import ignore it.

Any idea??

Thanks!

Import Excel Data To Database
Hello

I need to create a vb app that automates the process of importing data from an excel spreadsheet to a database. For now the type of database doesnt matter. However, the data in the excel worksheet is in a format thats making it difficult to import using VB.

The reason for the automation is that the data in the excel worksheet can change and therefore each time the app will run the automation will be done first to produce the data in a database format.

Hopefully someone will have some info on wheres best to start.

Import Data From Excel In Access
Hi all,

I want to make a small application, but I need your help.
This application will take data from Excel and must store them after
calculating, in Access.
I can make importing in Access by desing, but this i will be every day and I
want to make by code in VB
Do you have any code for importing data from Excel in Access with code by
VB.

I'm waiting your response.

Thank you very much
Entela

ASP - Import Data Frm Excel Sheet To ASP
Hello Friends

Is it possible for importing data frm Excel Sheet to ASP(SQL Server is my
back-end)

If any one knows plz help me out if possible send the source code for that

Thanks and Regards

Raju

Import Data From Excel To Sql Server
Dear Friends...

Can some one advice me with the code of how to import data from excel to
sql server using programming?



With Best Regards


Siraj

Import Excel Data To Ms Access
does anybody have a code either java or vb to import data from excel to ms access... and which do u think is the better programming language to use?

Import Excel Data Into A VB DataGrid
Can anyone tell me how to import data from an Excel spreadsheet into a VB datagrid?

Import Data From Excel To Access.
 Hi, I want to import data from Excel sheet while it is open and not saved,is it possible..
Exactly wht I mean is I m getting data in Excel sheet(I m using it as temp db) from other app. it is not being saved I want to read tht data and insert it into Access DB. it has 2 columns and around 10 rows and then delete tht Excel sheet data to get another data how to do so plz help me....

Import Data From Excel To Access
Hello,
I need to know how to make it easy to import data from an excel file into a access database. For example i have a access database, with an table, let's say "table1".
I have a form with a text box with a browse button , where i introduce the path for the excel file. I have a button "Update", and when i press it append the data from excel to my "Table1".

The ideea is that i want to centralize more excel files, same as structure in one access database, or excel without make copy/paste, or import.

Thx!

Import Excel Data Into MS Access
I need to import the data from Excel into MS Access database using VB 6.0. My excel file consists of 3 Tab Sheets. Each Tab Sheet contains data. First line in all the sheets are field names. I need to populate this data from each tab sheet into a table (table name should be the Tab sheet Name) in Access database.

Can anyone pls help me with this ? It's lil urgent for me. Appreciate your help.

Thanks,
josh

VBA: How To Import Data From OUTLOOK And EXCEL Via OLE?
hi all!

i'm looking for an easy way to import data from OUTLOOK and EXCEL into ACCESS via VBA and OLE.
do you have any links or examples?

thanks in advance,

muaddib

Import Data From Excel To Access
hello,

i have a data sheet in excel and i want to transfer the data into some tables in access.
is there a way to do it? and if so how?

thanks,
ohad

Import Data From Excel To Access
I have an application which has a function which imports data from an Excel file. I need to set a condition which requires my access database to be empty for Excel file to be imported. Or at least give warning if it is not.
this is what i have right now

If DBName = "" Then Call ConfigSetMain_Click
If DBName = "" Then Exit Sub

CommonDialog1.FileName = ""
CommonDialog1.DialogTitle = "Select Excel file to import from and click open..."
CommonDialog1.Filter = "MS Excel Files (*.xls)|*.xls|All Files (*.*)|*.*"


Right now its only checking for DBname. I need to check whether the DB is empty or not. What code do i need for it..

[Cimperiali: title edited to make it more related to question]

Import Access Data Into Excel
How can i (in vba code) access the records of a table, and then display them in a combobox on an excel sheet? I know there has to be a very easy way to do this, anybody out there know what it is?

thanks.

-Jason

Merge Data From Multiple Excel Sheets Into A Workbook
I need to create a utility in VB which picks up all the excel files from a specified directory. Assume each of these files have 3 sheets with data (text) in the same format. I need to create a new excel file with similar format containing the 3 sheets and merge the contents from all the source excel files into this new excel workbook.

Retrieving Data From Excel Workbook Using Odbc Driver
I want to retrieve data from excel workbook with odbc driver .
how the select statement should be coded for retrieving data from excel.

How To Import Data From Excel To Access Into Recordset
Hi,

I am making one application in Access and all data are in excel. I would like to know the source code in VBA which I can use for importing all of these data from excel to access into recordset. I need those data in recordset because then I know how can i work with them, select only those i need in certain table and so on...

dont recommend me docmd.transferspreadsheet or something like that... I need importing into recordset.

It will make me happy, if somebody will reply me and help me...

thank you...

Peter

Import Data From Excel To MYSQL Server
Hi all
hope some one can help me solve my problem.
Actually I want import data from excel to my MYSQL server by using VB6
I facing the problem on my coding and system show me the error.
below is my VB coding hope some one can tell me my error.
Thanks

Dim cn As ADODB.Connection
Dim sql As String
Dim lngrecsaff As Long

Set cn = New ADODB.Connection
cn.Open "DRIVER={MySQL ODBC 3.51 Driver};DSN='';DATABASE=" & DBName & ";SERVER=" & Server & ";UID=root;PASSWORD='password';PORT=3306;OPTION=3;S TMT=;"

sql = "select * into Ztable from " & _
"mydatabase('microsoft.jet.oledb.4.0'," & _
"'excel 8.0;database=C:insert testmak.xls', " & _
"'select * from [sheet1$]')"
Debug.Print sql
cn.Execute sql, ingrecsaff, adExecuteNoRecords
'strsql, lngrecsaff, adexcutenorecords
Debug.Print "records affected: " & ingrecsaff

cn.Close
Set cn = Nothing

Thank alot

Copyright © 2005-08 www.BigResource.com, All rights reserved