Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Type Mismatch Error 13

Why do I get the error? Oddly enough, I can use the commented line for the
debug.print, but when I try to assign to an array it gives the error.

I'm totally confused.

Bob

Dim FName as Variant
Set fs = Workbooks.Application.FileSearch
With fs
.LookIn = "E:\Stott\Inventory"
'.FileType = msoFileTypeExcelWorkbooks
.FileName = "Input??.xls"
.Execute
End With

For i = 1 To fs.FoundFiles.Count
FName(i) = fs.FoundFiles(i)
'Debug.Print fs.FoundFiles(i)
Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Type Mismatch Error 13

Hi

You need to redim your array after the End With statement:

Redim fName(1 to fs.foundfiles.count)

Hopes this helps.
....
Per


On 15 Jul., 22:55, Bob Zimski
wrote:
Why do I get the error? Oddly enough, I can use the commented line for the
debug.print, but when I try to assign to an array it gives the error.

I'm totally confused.

Bob

Dim FName as Variant
Set fs = Workbooks.Application.FileSearch
* *With fs
* * * .LookIn = "E:\Stott\Inventory"
* * * '.FileType = msoFileTypeExcelWorkbooks
* * * .FileName = "Input??.xls"
* * * .Execute
* *End With

* *For i = 1 To fs.FoundFiles.Count
* * * FName(i) = fs.FoundFiles(i)
* * * 'Debug.Print fs.FoundFiles(i)
* *Next i


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Type Mismatch Error 13

I tried it and it just gave a new error 'Subscript out of range.'
Like I eluded to earlier, if I commented out the line where I try to assign
FName and uncomment the debug.print, the debug print works and shows three
values as expected. While when I try to do the assignment it gives the Type
Mismatch Error 13.

Still a mystery to me.

Bob

"Per Jessen" wrote:

Hi

You need to redim your array after the End With statement:

Redim fName(1 to fs.foundfiles.count)

Hopes this helps.
....
Per


On 15 Jul., 22:55, Bob Zimski
wrote:
Why do I get the error? Oddly enough, I can use the commented line for the
debug.print, but when I try to assign to an array it gives the error.

I'm totally confused.

Bob

Dim FName as Variant
Set fs = Workbooks.Application.FileSearch
With fs
.LookIn = "E:\Stott\Inventory"
'.FileType = msoFileTypeExcelWorkbooks
.FileName = "Input??.xls"
.Execute
End With

For i = 1 To fs.FoundFiles.Count
FName(i) = fs.FoundFiles(i)
'Debug.Print fs.FoundFiles(i)
Next i



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Type Mismatch Error 13

Hi

This worked for me:

Dim FName As Variant
Set fs = Workbooks.Application.FileSearch
With fs
.LookIn = "E:\Stott\Inventory"
'.FileType = msoFileTypeExcelWorkbooks
.Filename = "Input??.xls"
.Execute
End With
ReDim FName(1 To fs.FoundFiles.Count)
For i = 1 To fs.FoundFiles.Count
FName(i) = fs.FoundFiles(i)
Debug.Print fs.FoundFiles(i)
Next i

Regards,
Per

"Bob Zimski" skrev i meddelelsen
...
I tried it and it just gave a new error 'Subscript out of range.'
Like I eluded to earlier, if I commented out the line where I try to
assign
FName and uncomment the debug.print, the debug print works and shows three
values as expected. While when I try to do the assignment it gives the
Type
Mismatch Error 13.

Still a mystery to me.

Bob

"Per Jessen" wrote:

Hi

You need to redim your array after the End With statement:

Redim fName(1 to fs.foundfiles.count)

Hopes this helps.
....
Per


On 15 Jul., 22:55, Bob Zimski
wrote:
Why do I get the error? Oddly enough, I can use the commented line for
the
debug.print, but when I try to assign to an array it gives the error.

I'm totally confused.

Bob

Dim FName as Variant
Set fs = Workbooks.Application.FileSearch
With fs
.LookIn = "E:\Stott\Inventory"
'.FileType = msoFileTypeExcelWorkbooks
.FileName = "Input??.xls"
.Execute
End With

For i = 1 To fs.FoundFiles.Count
FName(i) = fs.FoundFiles(i)
'Debug.Print fs.FoundFiles(i)
Next i




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Type Mismatch Error 13

Hi

Don't know why it worked for me now and not before. Must have been a brain
freeze.

Thanks much.

"Per Jessen" wrote:

Hi

This worked for me:

Dim FName As Variant
Set fs = Workbooks.Application.FileSearch
With fs
.LookIn = "E:\Stott\Inventory"
'.FileType = msoFileTypeExcelWorkbooks
.Filename = "Input??.xls"
.Execute
End With
ReDim FName(1 To fs.FoundFiles.Count)
For i = 1 To fs.FoundFiles.Count
FName(i) = fs.FoundFiles(i)
Debug.Print fs.FoundFiles(i)
Next i

Regards,
Per

"Bob Zimski" skrev i meddelelsen
...
I tried it and it just gave a new error 'Subscript out of range.'
Like I eluded to earlier, if I commented out the line where I try to
assign
FName and uncomment the debug.print, the debug print works and shows three
values as expected. While when I try to do the assignment it gives the
Type
Mismatch Error 13.

Still a mystery to me.

Bob

"Per Jessen" wrote:

Hi

You need to redim your array after the End With statement:

Redim fName(1 to fs.foundfiles.count)

Hopes this helps.
....
Per


On 15 Jul., 22:55, Bob Zimski
wrote:
Why do I get the error? Oddly enough, I can use the commented line for
the
debug.print, but when I try to assign to an array it gives the error.

I'm totally confused.

Bob

Dim FName as Variant
Set fs = Workbooks.Application.FileSearch
With fs
.LookIn = "E:\Stott\Inventory"
'.FileType = msoFileTypeExcelWorkbooks
.FileName = "Input??.xls"
.Execute
End With

For i = 1 To fs.FoundFiles.Count
FName(i) = fs.FoundFiles(i)
'Debug.Print fs.FoundFiles(i)
Next i




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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 05:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"