|
-
Mar 27th, 2000, 07:31 AM
#1
Thread Starter
New Member
I've set my references.....
heres my code:
-----------------------------------------------------------
Public Sub open_xls(filename As String)
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlapp = CreateObject("excel.application")
Set xlbook = xlapp.Workbooks.Open(filename)
Set xlsheet = xlbook.Worksheets(1)
morenum = 10
ReDim numbers(0 To morenum)
'place the value of the cells into variables
Dim n%
************PROBLEM RIGHT HERE**********
Do Until xlsheet.Cells(n, 1).Value = ""
************PROBLEM RIGHT HERE**********
I want my application to read until there it hits a cell w/no value!!!!
If n >= UBound(numbers) Then
Dim evenmorenums%
evenmorenums = morenum + morenum
ReDim Preserve numbers(0 To evenmorenums)
End If
With numbers(n)
.fname = xlsheet.Cells(n + 1, "a")
.phone = xlsheet.Cells(n + 1, "b")
n = n + 1
End With
Loop
ReDim Preserve numbers(LBound(numbers) To (n - 1))
Set xlsheet = Nothing
Set xlbook = Nothing
xlapp.Quit
Set xlapp = Nothing
End Sub
-
Apr 4th, 2000, 01:48 PM
#2
Lively Member
i think the problem is "n" is not initialized...
initialize it before the loop (Do Until xlsheet.Cells(n, 1).Value = "" )
hope this helps...
-
Apr 4th, 2000, 09:23 PM
#3
Thread Starter
New Member
i think the problem is "n" is not initialized...
initialize it before the loop (Do Until xlsheet.Cells(n, 1).Value = "" )
hope this helps...
I initialized n right before the Do Until .........
Dim n%........
my problem is that I get a type mismatch for this line when i run the program
Do Until xlsheet.Cells("n", 1).Value = ""
how would you go about reading an excel spreedsheet????
thanks for your help
Will
-
Apr 5th, 2000, 09:42 AM
#4
Lively Member
you declared or "dimmed" it...but not
initialized as in...
Code:
' dim - to make sure, make n an integer
dim n integer
' initialize n
n = 1
' loop
Do Until xlsheet.Cells(n, 1).Value = ""
' there should be no quotation marks around n
-
Apr 5th, 2000, 07:55 PM
#5
Thread Starter
New Member
you declared or "dimmed" it...but not
initialized as in...
Code:
' dim - to make sure, make n an integer
dim n integer
' initialize n
n = 1
' loop
Do Until xlsheet.Cells(n, 1).Value = ""
' there should be no quotation marks around n

Thanks i'm gonna try it out when i get home! I really appreciate it!
Will
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|