Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2006

    Unanswered: Type mismatch error

    Hi: Can any one please tell me why it gives type mismatch error on line:
    arrNumbers(i, Row) = xlWS.Cells(Row, i)

    Private Sub Form_Load()
    End Sub

    Private Sub readExcelFile()
    Dim arrMyArray(0, 26) As String
    Dim intX As Integer
    Dim intY As Integer
    Dim xlApp As Excel.Application
    Dim xlWb As Excel.Workbook
    Dim xlWS As Excel.Worksheet
    Dim rngColumn As Excel.Range
    Dim rngCell As Excel.Range
    Dim strDestination As String
    Dim mysheet As String
    Dim lngRow As Long
    Set xlApp = New Excel.Application
    strSource = "C:\REMITandNSF\Remitence.xls"
    Set xlWb = xlApp.Workbooks.Open(strSource)
    mysheet = xlApp.Worksheets(1).Name
    Set xlWS = xlWb.Worksheets(mysheet)
    Dim wsEOF As Boolean
    Dim Row As Integer
    Dim arrNumbers(1 To 27, 1 To 100) As Long
    wsEOF = False
    Row = 2

    Do While wsEOF = False
    For i = 1 To 27
    arrNumbers(i, Row) = xlWS.Cells(Row, i)
    Next i
    Row = Row + 1
    If Row > 100 Then
    MsgBox ("Too many rows")
    wsEOF = True
    ElseIf xlWS.Cells(Row, 1) = 0 Then
    MsgBox ("End of File")
    wsEOF = True
    End If

    End Sub

  2. #2
    Join Date
    Jul 2003
    My first guess would be that xlWS.Cells(Row, i) contains a value that doesn't convert to data type Long.
    Inspiration Through Fermentation

  3. #3
    Join Date
    Jun 2004
    Arizona, USA
    to find out wich cell, add

    debug.print i,row

    immediately before the line which is throwing the error.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Posting Permissions

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