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

I have the following code:

Sub Consolidate()
Dim MyPath As String, FilesInPath As String
Dim MyFiles() As String, Fnum As Long
Dim mybook As Workbook
Dim CalcMode As Long
Dim sh As Worksheet
Dim ErrorYes As Boolean
Dim DCLastRow As Integer 'DirectorCopy
Dim MCLastRow As Integer 'Monthly Compiler

Dim Center(18) As String
Center(1) = "Bardstown"
Center(2) = "Bothell"
Center(3) = "VCollinsville"
Center(4) = "El Paso"
Center(5) = "Evansville"
Center(6) = "Greensboro"
Center(7) = "VHeathrow"
Center(8) = "Joplin"
Center(9) = "Kennesaw"
Center(10) = "Lafayette"
Center(11) = "Malvern"
Center(12) = "VManhattan"
Center(13) = "VMansfield"
Center(14) = "VOttawa"
Center(15) = "VPonco City"
Center(16) = "VReno"
Center(17) = "VSioux City"
Center(18) = "VTerra Haute"

Dim FileCount As Long
Dim ScoringAve As Double
Dim i As Long


'Fill in the path\folder where the files are
MyPath = "X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in
Progress\Centers"

For i = 1 To 18

' 'Add a slash at the end if the user forget it
' If Right(MyPath, 1) < "\" Then
' MyPath = MyPath & "\"
' End If

'If there are no Excel files in the folder exit the sub
FilesInPath = Dir(MyPath \ Center(i) & "*.xl*")

FilesInPath = Dir(MyPath \ Center(i) & "*.xl*") is giving error 13 Type
Mismatch. What am I doing wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default Type Mismatch

Bishop wrote:
I have the following code:

Sub Consolidate()
Dim MyPath As String, FilesInPath As String
Dim MyFiles() As String, Fnum As Long
Dim mybook As Workbook
Dim CalcMode As Long
Dim sh As Worksheet
Dim ErrorYes As Boolean
Dim DCLastRow As Integer 'DirectorCopy
Dim MCLastRow As Integer 'Monthly Compiler

Dim Center(18) As String
Center(1) = "Bardstown"
Center(2) = "Bothell"
Center(3) = "VCollinsville"
Center(4) = "El Paso"
Center(5) = "Evansville"
Center(6) = "Greensboro"
Center(7) = "VHeathrow"
Center(8) = "Joplin"
Center(9) = "Kennesaw"
Center(10) = "Lafayette"
Center(11) = "Malvern"
Center(12) = "VManhattan"
Center(13) = "VMansfield"
Center(14) = "VOttawa"
Center(15) = "VPonco City"
Center(16) = "VReno"
Center(17) = "VSioux City"
Center(18) = "VTerra Haute"

Dim FileCount As Long
Dim ScoringAve As Double
Dim i As Long


'Fill in the path\folder where the files are
MyPath = "X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in
Progress\Centers"

For i = 1 To 18

' 'Add a slash at the end if the user forget it
' If Right(MyPath, 1) < "\" Then
' MyPath = MyPath & "\"
' End If

'If there are no Excel files in the folder exit the sub
FilesInPath = Dir(MyPath \ Center(i) & "*.xl*")

FilesInPath = Dir(MyPath \ Center(i) & "*.xl*") is giving error 13 Type
Mismatch. What am I doing wrong?


Probably just a little programmer's moment with the backslash...

FilesInPath = Dir(MyPath & Center(i) & "*.xl*")
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Type Mismatch

A moment, indeed. That was it. Thanks!

"smartin" wrote:

Bishop wrote:
I have the following code:

Sub Consolidate()
Dim MyPath As String, FilesInPath As String
Dim MyFiles() As String, Fnum As Long
Dim mybook As Workbook
Dim CalcMode As Long
Dim sh As Worksheet
Dim ErrorYes As Boolean
Dim DCLastRow As Integer 'DirectorCopy
Dim MCLastRow As Integer 'Monthly Compiler

Dim Center(18) As String
Center(1) = "Bardstown"
Center(2) = "Bothell"
Center(3) = "VCollinsville"
Center(4) = "El Paso"
Center(5) = "Evansville"
Center(6) = "Greensboro"
Center(7) = "VHeathrow"
Center(8) = "Joplin"
Center(9) = "Kennesaw"
Center(10) = "Lafayette"
Center(11) = "Malvern"
Center(12) = "VManhattan"
Center(13) = "VMansfield"
Center(14) = "VOttawa"
Center(15) = "VPonco City"
Center(16) = "VReno"
Center(17) = "VSioux City"
Center(18) = "VTerra Haute"

Dim FileCount As Long
Dim ScoringAve As Double
Dim i As Long


'Fill in the path\folder where the files are
MyPath = "X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in
Progress\Centers"

For i = 1 To 18

' 'Add a slash at the end if the user forget it
' If Right(MyPath, 1) < "\" Then
' MyPath = MyPath & "\"
' End If

'If there are no Excel files in the folder exit the sub
FilesInPath = Dir(MyPath \ Center(i) & "*.xl*")

FilesInPath = Dir(MyPath \ Center(i) & "*.xl*") is giving error 13 Type
Mismatch. What am I doing wrong?


Probably just a little programmer's moment with the backslash...

FilesInPath = Dir(MyPath & Center(i) & "*.xl*")

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
type mismatch geebee Excel Programming 3 October 9th 08 02:58 PM
Type Mismatch [email protected] Excel Worksheet Functions 1 May 16th 07 03:29 PM
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM


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

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

About Us

"It's about Microsoft Excel"