+ Reply to Thread
Results 1 to 3 of 3

Type mismatch error: Need help

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2010
    Posts
    10

    Question Type mismatch error: Need help

    Hello Friends,
    I have typed the following code and there is a type mismatch error at the last line. Please help.

    Sub ConsolidatePDCA_Test()
    Dim sourceExcel As Workbook
    Dim destExcel As Workbook
    Dim destSheet, plbfdValue, plbfdimValue, plbfdneValue As String
    Dim imCount, neCount, tempCount As Integer
    Dim unitCell As Range
    Dim unitCell2 As Range
    Dim posRange, posRange2 As Range
    Dim rowCursor As Range
    Dim plantValue, bfdValue, mmyyyValue, ctgyValue As String
    Dim mainFolder, sFolder, ssFolder, objFSO, xlFile

    Set destExcel = ActiveWorkbook
    destSheet = "Master_Data"
    Set rowCursor = Range("A7")

    plantValue = Sheets("Dock").Range("F3").value
    bfdValue = Sheets("Dock").Range("F4").value
    mmyyValue = Sheets("Dock").Range("F5").Text
    ctgyValue = Sheets("Dock").Range("F6").value


    Set objFSO = CreateObject("Scripting.FileSystemObject")

    ' myFileNames = Split(LCase(Range("a1")), ";")
    Set mainFolder = objFSO.GetFolder("C:\Users\g41468\Desktop\01_Management_Meetings - Copy\")

    For Each sFolder In mainFolder.subfolders
    For Each ssFolder In sFolder.subfolders
    If ssFolder.Name Like "*" & mmyyValue & "*" Then
    For Each xlFile In ssFolder.Files
    If xlFile.Name Like "PDCA*" & "*.xls" Then

    '////////////Loop starts
    Set sourceExcel = Application.Workbooks(xlFile).Open

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Type mismatch error: Need help

    hi Lui23, correct syntax for Workbooks.Open method is:

    expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, ...)

    Example:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Type mismatch error: Need help

    Try something like this...

    Set sourceExcel = Application.Workbooks(ssFolder.Path & "\" & xlFile.Name).Open

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1