Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 2nd, 2005, 11:41 AM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default expporting data from a Excel file and showing it

how can i do this?

first i have to create a excel object right?

and then what?





Reply With Quote
  #2 (permalink)  
Old March 2nd, 2005, 12:13 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

importing.. sorry


Reply With Quote
  #3 (permalink)  
Old March 2nd, 2005, 12:48 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

A little more details ´what are you doing. Importing from etc.



Reply With Quote
  #4 (permalink)  
Old March 2nd, 2005, 01:03 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I´m trying to import an excel sheet with "n" rows and 2 columns into variables inside vb 6...

i´m trying to do a sort of select ( sql style) , that´s why i need to import the data from the excel sheet...



Reply With Quote
  #5 (permalink)  
Old March 2nd, 2005, 02:01 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

You must first set reference to Microsoft Excel library

Here is an example how to read Excel table to an array

Sub Load_Data()
Dim xlApp As Excel.Application
Dim Table
Set xlApp = New Excel.Application
xlApp.Workbooks.Open FileName:="File.xls"
'*** Takes whole table to an array
Table = xlApp.ActiveSheet.Range("A1").CurrentRegion
xlApp.Quit
Set xlApp = Nothing
End Sub


-vemaju


Reply With Quote
  #6 (permalink)  
Old March 2nd, 2005, 02:17 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

but that code sample only works for one collumn right?

Reply With Quote
  #7 (permalink)  
Old March 2nd, 2005, 02:22 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for example:


i have the following excel table for e.g.:

user Id | number
----------------
1 | 0
1 | 2
2 | 1


and i want to return the data referent to the user with id=1

for eg:

select *
from table
where userId =1

How can I transcribe this into Vb???

But then i want to set the results of this select into some variables...

Reply With Quote
  #8 (permalink)  
Old March 3rd, 2005, 10:17 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Bournemouth, Dorset, United Kingdom.
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What are you doing with the data once it's in VB6?


Reply With Quote
  #9 (permalink)  
Old March 4th, 2005, 05:51 PM
Authorized User
 
Join Date: Feb 2005
Location: , , Netherlands.
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

without opening the workbook with the worksheet u need data from, try this:

path = [path where the file is located] (with \ at the end)
filename= [workbook where data has to be collected]
sheetname = [sheet from worbook with data]
'
string = "'" & path & "[" & filename & "]" & sheetname & "'!" & "r" & i & "c" & j
(i represents the row, j represents the column)
value = ExecuteExcel4Macro(string)

put this piece of code in a loop and your done
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read data from an excel file diegoblin Beginning VB 6 6 September 1st, 2009 12:04 AM
Read Data from Excel File kiwibey ASP.NET 2.0 Professional 1 December 5th, 2006 11:27 AM
Creating an excel file and showing on the form dotnetprogrammer C# 0 May 3rd, 2005 08:36 AM
How to get data in an excel file ? stevenThu Classic ASP Databases 0 September 3rd, 2003 10:03 PM



All times are GMT -4. The time now is 11:56 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.