Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel 2007: Copy from recordset not working properly

Hi All,

I am facing a peculiar problem in Excel 2007. I have sheet with approx
76,000 rows of data and around 30 columns. I am trying to query the
sheet and copy data to another sheet. Strangely every time, the only
10,774 rows of data get copied. Just to check if my code is correct, I
opened a new workbook, created a coloumn with numbers running from 1
to 76000 and entered the following macro:

__________________________________________________ ________________________________
Sub pull()

Application.ScreenUpdating = False
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Dim Sheetname As String
Set cn = New ADODB.Connection

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & ThisWorkbook.FullName & ";" &
_
"Extended Properties=Excel 8.0;"
.Open
End With
Sheetname = "Sheet1"

querystr = "Select * from [" & Sheetname & "$] "

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = querystr
cmd.CommandType = adCmdText
cmd.CommandTimeout = 0

Set rs = cmd.Execute()

Sheets("Sheet2").Range("A2").CopyFromRecordset rs
rs.Close

End Sub
__________________________________________________ ________________________________

When I ran the macro, it only copied 10,463 rows!!! Any idea why this
is happening and what is the workaround for this?

Thanks in advance,
Indrajit
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Excel 2007: Copy from recordset not working properly

I can't check this , but maybe your extended properties should refer to a
later version of excel than 8.0 ?


"Indrajit" wrote:

Hi All,

I am facing a peculiar problem in Excel 2007. I have sheet with approx
76,000 rows of data and around 30 columns. I am trying to query the
sheet and copy data to another sheet. Strangely every time, the only
10,774 rows of data get copied. Just to check if my code is correct, I
opened a new workbook, created a coloumn with numbers running from 1
to 76000 and entered the following macro:

__________________________________________________ ________________________________
Sub pull()

Application.ScreenUpdating = False
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Dim Sheetname As String
Set cn = New ADODB.Connection

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & ThisWorkbook.FullName & ";" &
_
"Extended Properties=Excel 8.0;"
.Open
End With
Sheetname = "Sheet1"

querystr = "Select * from [" & Sheetname & "$] "

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = querystr
cmd.CommandType = adCmdText
cmd.CommandTimeout = 0

Set rs = cmd.Execute()

Sheets("Sheet2").Range("A2").CopyFromRecordset rs
rs.Close

End Sub
__________________________________________________ ________________________________

When I ran the macro, it only copied 10,463 rows!!! Any idea why this
is happening and what is the workaround for this?

Thanks in advance,
Indrajit
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel 2007: Copy from recordset not working properly

There is another connection string for 2007

I use this

szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=Yes"";"

In the code on this page
http://www.rondebruin.nl/ado.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Patrick Molloy" wrote in message
...
I can't check this , but maybe your extended properties should refer to a
later version of excel than 8.0 ?


"Indrajit" wrote:

Hi All,

I am facing a peculiar problem in Excel 2007. I have sheet with approx
76,000 rows of data and around 30 columns. I am trying to query the
sheet and copy data to another sheet. Strangely every time, the only
10,774 rows of data get copied. Just to check if my code is correct, I
opened a new workbook, created a coloumn with numbers running from 1
to 76000 and entered the following macro:

__________________________________________________ ________________________________
Sub pull()

Application.ScreenUpdating = False
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Dim Sheetname As String
Set cn = New ADODB.Connection

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & ThisWorkbook.FullName & ";" &
_
"Extended Properties=Excel 8.0;"
.Open
End With
Sheetname = "Sheet1"

querystr = "Select * from [" & Sheetname & "$] "

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = querystr
cmd.CommandType = adCmdText
cmd.CommandTimeout = 0

Set rs = cmd.Execute()

Sheets("Sheet2").Range("A2").CopyFromRecordset rs
rs.Close

End Sub
__________________________________________________ ________________________________

When I ran the macro, it only copied 10,463 rows!!! Any idea why this
is happening and what is the workaround for this?

Thanks in advance,
Indrajit
.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel 2007: Copy from recordset not working properly

Hi Ron,

I tried using your string, but it throws up an error saying "Could not
find installable ISAM"!

Any suggestions?

Regards,
Indrajit

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel 2007: Copy from recordset not working properly

Hi Indrajit

Is the code in my example workbook working Correct ?

Do you use Late or Early binding ?
Maybe you must set a reference in the VBA editor


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Indrajit" wrote in message ...
Hi Ron,

I tried using your string, but it throws up an error saying "Could not
find installable ISAM"!

Any suggestions?

Regards,
Indrajit

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Fill function in Excel 2007 not working properly Raudawg Excel Worksheet Functions 5 April 3rd 23 01:27 PM
Some charts won't copy properly from Excel 2007 Jeff in GA Excel Discussion (Misc queries) 6 September 11th 09 01:01 AM
Excel Copy, Paste not working properly, corrupts file Marvin B Excel Discussion (Misc queries) 1 March 3rd 09 04:21 PM
Top Property in Excel 2007 Not Working Properly TGATOR Excel Programming 0 July 24th 08 08:38 PM
PAGE PREVIEW NOT WORKING PROPERLY IN EXCEL 2007 Scott Dixon Excel Worksheet Functions 0 July 4th 06 03:52 PM


All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"