Accessing Excel pages using VB

B

bob_mhc

Hi. I'm wondering if any of you can help me with a problem I'm having. It's
likely a trivial answer, but I'm not seeing it at the moment.

I'm using VB 6.0 and Excel 2002.

I have an Excel workbook that has information about days of the month --
each day having an individual spreadsheet 'Day (1)', 'Day (2)', etc. as tabs
along the bottom of the workbook. I want to be able to access information
from individual "days" using a VB application and do some processing and then
printing of the data in VB.

First of all, when addressing data on spreadsheet Day(k) of the workbook,
how do I do that. For instance, using

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet as Excel.Worksheet
Dim row As Integer

Then later on I may use:

txtAmount.Text = xlSheet.Cells(row, 5).Value

but I need some way to identify 'Day (16)' as the worksheet that I'm
actually working on in this line. And, I want to have the "16" as something
I enter in a textbox at runtime to identify the day that I want to work on.
Then another time, I would use 'Day (9)', and so forth.

Can anyone help me on those things?

Many thanks,
Bob
 
M

Mangus Pyke

First of all, when addressing data on spreadsheet Day(k) of the workbook,
how do I do that. For instance, using

Workbooks("Filename.xls").Sheets("Day(k)").Range("A1 or
whatever").Value

If you always have the days in the same order, you can also use:
Workbooks("Filename.xls").Sheets.Item(*index_number*).Value..

In other words, if your second worksheet is Day (2), then you could
address it by calling:
Workbooks("Filename.xls").Sheets.Item(2)
but I need some way to identify 'Day (16)' as the worksheet that I'm
actually working on in this line. And, I want to have the "16" as something
I enter in a textbox at runtime to identify the day that I want to work on.
Then another time, I would use 'Day (9)', and so forth.

So call an InputBox and set the response to a variable, such as TabDay
and then call your worksheets using:
Workbooks("Filename.xls").Sheets.Item(TabDay)
Can anyone help me on those things?

Was that helpful or more confusing?

MP-
 
Top