Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Import extrenal data exceeds 65536

"AA2e72E" wrote ...

I don't have any sample code to hand: I can suggest some ideas.

ADO has a pagesize
(no of rows) property which you can set to 65536 & then loop through the
PageCount property to retrieve all records.


Could you post some code that demonstrates how to this, please?

Many thanks,
Jamie.

--
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Import extrenal data exceeds 65536

Here's some code, annotated and tested: I have used a WORKBOOK as the source
data, modify the code to use another source.

Sub Partition2()
'Get the Source data
Cnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\ajay2.xls;Extended Properties=Excel 8.0;"
Sql = "SELECT * FROM [Sheet1]"
Set ADORS = CreateObject("ADODB.RecordSet")
'Number of records in a single sheet
ADORS.PageSize = 20000
ADORS.Open Sql, Cnn, 1, 3 ' adOpenKeySet, adLockOptimistic
'Create Excel Workbook ...
Set xl = CreateObject("Excel.Application")
'Hold user's default number of sheets
UserWBS = xl.SheetsInNewWorkbook
With ADORS
'... with the right number of worksheets to hold all records
xl.SheetsInNewWorkbook = .PageCount
xl.Workbooks.Add
xl.SheetsInNewWorkbook = UserWBS
xl.Sheets.Select
xl.Sheets(1).Activate
'Add field names to Row 1 in all sheets
For i = 0 To .Fields.Count - 1
xl.Cells(1, i + 1).Select
xl.Selection.Font.Bold = True
xl.Selection.FormulaR1C1 = .Fields(i).Name
Next
'Populate each sheet in turn
For i = 1 To .PageCount
xl.Sheets(i).Select
xl.Range("A2").CopyFromRecordset ADORS, .PageSize, 256
Next
xl.Sheets(1).Select
xl.Sheets(1).Range("A1").Select
End With
' Tidy up
ADORS.Close
Set ADORS = Nothing
' Make Excel visible, user must decide to save it or not
xl.Visible = 1
Set xl = Nothing
End Sub

"Jamie Collins" wrote:

"AA2e72E" wrote ...

I don't have any sample code to hand: I can suggest some ideas.

ADO has a pagesize
(no of rows) property which you can set to 65536 & then loop through the
PageCount property to retrieve all records.


Could you post some code that demonstrates how to this, please?

Many thanks,
Jamie.

--

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
Data exceeds chart limits Rebecca Charts and Charting in Excel 2 March 25th 08 12:16 AM
How Can I import external data what is more than 65536 lines? KurtHan71 Excel Discussion (Misc queries) 2 February 14th 08 01:51 PM
How do I import data into Excel that exceeds 70000 rows? Claudia Phelps Excel Discussion (Misc queries) 2 March 25th 05 11:33 PM
Import extrenal data exceeds 65536 TK Excel Programming 9 November 29th 04 08:10 AM
Import extrenal data exceeds 65536 Tim Williams Excel Programming 0 November 24th 04 02:18 AM


All times are GMT +1. The time now is 07:53 AM.

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"