Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default filling sheets with Oracle ????

Hi,

I'm trying to write a procedure that will send 65000 records by
sheet. I'm creating the sheet dynamically. Programming in excel is new and
I'm still not sure how to call the objects of the workbook. I'm not sure if
sh is at the right place and if I can switch the sheet number with a
variable.....Can you help me?

Public Sub odbc()
Dim rng As range
Dim sh As Worksheet
Set sh = ActiveSheet

Dim SheetNumber
Dim NumberOfRecord
Dim Partition
'total nuber of record
NumberOfRecord = oraDynaSet.RecordCount
'number of sheets that will have 65000 and the last one with less
Partition = NumberOfRecord / 65000

Set objSession = CreateObject("OracleInProcServer.XOraSession")
Set objDatabase = objSession.OpenDatabase("", "Userid/Pwd", 0)

Sql = "select * from Table"

Set oraDynaSet = objDatabase.DBCreateDynaset(Sql, 0)
'First sheet to fill out
If oraDynaSet.RecordCount 0 And oraDynaSet.RecordCount <= 65000 Then
oraDynaSet.MoveFirst
'Header
For x = 0 To oraDynaSet.Fields.Count - 1
sh.Cells(1, x + 1) = oraDynaSet.Fields(x).Name
sh.Cells(1, x + 1).Format = Bold
Next
'Records
For Y = 0 To oraDynaSet.RecordCount - 1
For x = 0 To oraDynaSet.Fields.Count - 1
sh.Cells(Y + 2, x + 1) = oraDynaSet.Fields(x).Value
Next
oraDynaSet.MoveNext
Next
End If

'the first partition is done
Partition = Partition - 1

'other sheets

For SheetNumber = 1 To Partition
'creating a new sheet by calling a procedure
Createsheet ("sheet#" & SheetNumber)
'Going in the intervals
'65001 - 130 000 in sheet#1
'130001 - 195000 in sheet#2
'195001 - 260000 in sheet#3
' .... up to Partition

sh.Select (SheetNumber) ????????????????????????? how can I go to
another sheet from VB?

If oraDynaSet.RecordCount ((SheetNumber * 65000) + 1) And_
oraDynaSet.RecordCount <= ((SheetNumber + 1) * 65000) Then
For Y = 0 To oraDynaSet.RecordCount - 1
For x = 0 To oraDynaSet.Fields.Count - 1
sh.Cells(Y + 2, x + 1) = oraDynaSet.Fields(x).Value
Next
oraDynaSet.MoveNext
Next
End If
Next


Set objSession = Nothing
Set objDatabase = Nothing
End Sub
thanx
Jack
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
SQL for Oracle David Excel Discussion (Misc queries) 2 September 26th 06 04:28 PM
XL 2003 Automatically filling in cells on two sheets on opening... Birmangirl Excel Discussion (Misc queries) 1 August 9th 06 08:16 AM
Auto filling cells across mutliple sheets Alec H Excel Discussion (Misc queries) 5 February 6th 06 02:39 PM
Connect to Oracle using Microsoft ODBC for Oracle Kent Excel Programming 2 January 18th 06 03:53 AM
filling information from one cell and filling another. Dianne Excel Worksheet Functions 1 August 15th 05 08:14 PM


All times are GMT +1. The time now is 03:20 AM.

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

About Us

"It's about Microsoft Excel"