Pulling Data from an Excel Workbook.

  • Thread starter Thread starter lmefford
  • Start date Start date
L

lmefford

Alright, I've got a bit of a dilemma so I figured I would actually ask
for some help.

My girlfriend and I have been working on a program that she got
commissioned to do for her brother and the gas station that he works
at. It's a fairly straight-forward program; they are wanting to be
able to save gas prices at various stations and the sort so that they
can pull it up later and compare them (don't ask why the store owner
doesn't set up particular workbooks and the sort). We've gotten down
having the form take the textbox entries from 5 tabs and saving it all
to a 5 paged workbook. I also have (I think) the printing down with
the simple xlApp.ActiveWorkbook.PrintOutEx.

However, the problem that we are having seems to have an elusive
answer: Once we have a workbook loaded to read from, how do we take
the contents of a particular cell or a range of cells and bring it up
in a textbox or group of textboxes?
 
Alright, I've got a bit of a dilemma so I figured I would actually ask
for some help.

My girlfriend and I have been working on a program that she got
commissioned to do for her brother and the gas station that he works
at. It's a fairly straight-forward program; they are wanting to be
able to save gas prices at various stations and the sort so that they
can pull it up later and compare them (don't ask why the store owner
doesn't set up particular workbooks and the sort). We've gotten down
having the form take the textbox entries from 5 tabs and saving it all
to a 5 paged workbook. I also have (I think) the printing down with
the simple xlApp.ActiveWorkbook.PrintOutEx.

However, the problem that we are having seems to have an elusive
answer: Once we have a workbook loaded to read from, how do we take
the contents of a particular cell or a range of cells and bring it up
in a textbox or group of textboxes?

You can use the worksheet's .Range() method to select a single or
range of cells.

IIRC Range("A1") selects a single cell, while Range("A1:B3") would
select the group of cells. You should look up the Range() function in
the Object Browser or using Excel's VBA help - it should give you
sample code.

Also, do you have to use Excel? If all the information is set and
retrieved through your program it would probably be easier to use an
Xml file or a dedicated database for this.

Thanks,

Seth Rowe
 
You can use the worksheet's .Range() method to select a single or
range of cells.

IIRC Range("A1") selects a single cell, while Range("A1:B3") would
select the group of cells. You should look up the Range() function in
the Object Browser or using Excel's VBA help - it should give you
sample code.

Also, do you have to use Excel? If all the information is set and
retrieved through your program it would probably be easier to use an
Xml file or a dedicated database for this.

Thanks,

Seth Rowe

Well we don't have to but considering we don't have a lot of
experience with databases as well as the fact that the excel workbook
takes a lot less space we decided to go with something that would
still stand even if, for some unforseen reason, our program failed to
do something. The woman we are doing this for is extremely computer
illiterate and as such if something went wrong with our computer, she
would be in the dark as to how to use the database or an xml. Both of
those options were looked at, though.
 
Well we don't have to but considering we don't have a lot of
experience with databases as well as the fact that the excel workbook
takes a lot less space we decided to go with something that would
still stand even if, for some unforseen reason, our program failed to
do something. The woman we are doing this for is extremely computer
illiterate and as such if something went wrong with our computer, she
would be in the dark as to how to use the database or an xml. Both of
those options were looked at, though.

Ah! I've found it. Since we have each of the 5 worksheets set to
different variables it is fairly simple now that I have got the
Range() function working the way I wanted it to:
worksheetvariable.range("cell").value
gave me the precise results.
 
Back
Top