Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Recordset in Excel

Hi,

How do I create a recordset based on a range of cells?

I assume that a row will constitute a record?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Recordset in Excel

Define what you mean by RecordSet. Are you using ADO, DAO, what?

Is the Excel file open or closed? Where are you doing this from?

--
Regards,
Tom Ogilvy

"Newbie" wrote in message
...
Hi,

How do I create a recordset based on a range of cells?

I assume that a row will constitute a record?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Recordset in Excel

First you have to reference the DAO or ADO library.
Current best approach is to use ADO 2.7 (if that's still
the latest version). Then I think all you can do is loop
through the range of cells and append values from
selected columns into the recordset. For example:

Dim rs As ADODB.Recordset
Dim wb As Workbook
Dim ws As Worksheet
Dim i As Long

Set rs = New ADODB.Recordset
Set wb = ThisWorkbook
Set ws = wb.ActiveSheet

rs.Fields.Append "Field1", adBSTR
rs.Fields.Append "Field2", adBSTR
rs.Open

For i = 1 To 50
rs.AddNew
rs("Field1").Value = ws.Cells(i, 1).Value
rs("Field2").Value = ws.Cells(i, 2).Value
rs.Update
Next


-----Original Message-----
Hi,

How do I create a recordset based on a range of cells?

I assume that a row will constitute a record?


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Recordset in Excel

Mike's is an example of a fabricated recordset. I'll point out the
obvious: you can also use ADO to connect to the workbook using the MS
OLEBD provider for JET and create an *updateable* recordset based on a
SQL SELECT query.

--

"Mike" wrote in message ...
First you have to reference the DAO or ADO library.
Current best approach is to use ADO 2.7 (if that's still
the latest version). Then I think all you can do is loop
through the range of cells and append values from
selected columns into the recordset. For example:

Dim rs As ADODB.Recordset
Dim wb As Workbook
Dim ws As Worksheet
Dim i As Long

Set rs = New ADODB.Recordset
Set wb = ThisWorkbook
Set ws = wb.ActiveSheet

rs.Fields.Append "Field1", adBSTR
rs.Fields.Append "Field2", adBSTR
rs.Open

For i = 1 To 50
rs.AddNew
rs("Field1").Value = ws.Cells(i, 1).Value
rs("Field2").Value = ws.Cells(i, 2).Value
rs.Update
Next


-----Original Message-----
Hi,

How do I create a recordset based on a range of cells?

I assume that a row will constitute a record?


.

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
Display a Recordset in Excel Alex A Excel Programming 5 October 31st 03 10:13 PM
Excel 2000 - VBA - Stop recordset Data from auto converting Matt. Excel Programming 2 September 25th 03 01:22 PM
Excel 2000 VBA recordset manipulation Matt. Excel Programming 2 September 16th 03 03:59 PM
Recordset Opening Excel File Seth[_3_] Excel Programming 0 August 1st 03 01:52 PM
open range (within workbook) as ado recordset - excel vba S. Daum Excel Programming 0 July 25th 03 04:45 PM


All times are GMT +1. The time now is 07:03 PM.

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"