Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Retrieving data from Excel and store it into string variable


Oooppssss, my bad. Missed out that line.


Code:
--------------------
Dim strName As String
Dim strPosition as String

Dim objExcel As Object
Set objExcel = CreateObject("ADODB.Recordset")

Dim rsData as ADODB.RecordSet
Set rsData = New ADODB.RecordSet
--------------------


After I have opened the connection of the spreadsheet, all the data are
stored in objExcel.

After I have opened the connection to my database, all the data are
stored in rsData which then will be used as filter.


Code:
--------------------
objExcel.MoveFirst

Do While Not objExcel.EOF
strPosition = objExcel.Fields("Position").Value

rsData.Filter = "Position = ' " & strPosition & " ' "

If Not rsData.EOF Then
strName = objExcel.Fields("Name").Value
End If

objExcel.MoveNext
Loop
--------------------


--
marsulein
------------------------------------------------------------------------
marsulein's Profile: http://www.excelforum.com/member.php...o&userid=16064
View this thread: http://www.excelforum.com/showthread...hreadid=275204

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Retrieving data from Excel and store it into string variable

marsulein,
Why do you use 2 different methods to achieve the same ?

1. Dim objExcel As Object
Set objExcel = CreateObject("ADODB.Recordset")


2. Dim rsData as ADODB.RecordSet
Set rsData = New ADODB.RecordSet


I'm still not clear if you are using VBA in Excel or VB to achieve this ?

NickHK


"marsulein" wrote in message
...

Oooppssss, my bad. Missed out that line.


Code:
--------------------
Dim strName As String
Dim strPosition as String

Dim objExcel As Object
Set objExcel = CreateObject("ADODB.Recordset")

Dim rsData as ADODB.RecordSet
Set rsData = New ADODB.RecordSet
--------------------


After I have opened the connection of the spreadsheet, all the data are
stored in objExcel.

After I have opened the connection to my database, all the data are
stored in rsData which then will be used as filter.


Code:
--------------------
objExcel.MoveFirst

Do While Not objExcel.EOF
strPosition = objExcel.Fields("Position").Value

rsData.Filter = "Position = ' " & strPosition & " ' "

If Not rsData.EOF Then
strName = objExcel.Fields("Name").Value
End If

objExcel.MoveNext
Loop
--------------------


--
marsulein
------------------------------------------------------------------------
marsulein's Profile:

http://www.excelforum.com/member.php...o&userid=16064
View this thread: http://www.excelforum.com/showthread...hreadid=275204



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
To store the formula in a string pol Excel Discussion (Misc queries) 4 December 2nd 08 02:14 PM
retrieving data from variable workbooks lutan Excel Discussion (Misc queries) 3 August 14th 07 01:08 PM
Retrieving Cell Data From Variable Files DJ Pomeroy Excel Worksheet Functions 3 April 24th 07 08:32 PM
Retrieving data from Excel and store it into string variable marsulein Excel Programming 2 November 9th 04 08:44 AM
Retrieving data from Excel and store it into string variable marsulein[_2_] Excel Programming 1 November 9th 04 02:04 AM


All times are GMT +1. The time now is 11:59 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"