Results 1 to 3 of 3

Data Type Mismatch Error

Threaded View

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    Seattle, WA
    MS-Off Ver
    Office 365
    Posts
    67

    Question Data Type Mismatch Error

    I'm working on a project to add up the width of rolls (WIDTH ORD) from a given parent roll identified by LENGTH. I only want to analyze parent rolls that have associated pattern numbers that are not integers. i.e. analyze rows with values 5.1, 6.2 but not 5, 6, 7 etc.

    I added an excel file with some column values deleted for ease of reading.

    Here is my full code

    Option Explicit
    
    Sub calc()
        Dim LastRow As Integer
        Dim sum As Integer
        Dim x As Integer
        Dim i As Integer
        
        LastRow = ActiveSheet.UsedRange.Rows.Count
        sum = 0
        x = 1
        
        'Sets column S as integer of column K
        'Subtracts column S from column K and outputs in column T
        'Allows me to distinguish data I want to delete
        For i = 1 To LastRow
            Cells(i, "S").Value = Int(Cells(i, "K"))
            Cells(i, "T").Value = Cells(i, "K").Value - Cells(i, "S").Value
        Next i
    
        'Deletes rows that contain 0s in column T
        'Deletes data I don't want to analyze
        For i = 1 To LastRow
            If Cells(i, "T").Value = 0 Then
            Rows(i).Delete
            End If
        Next i
        
        'Sums the values in column E for all rows that have the same value in column I
        'Reports sums to column V
        'Sums the width of each pattern roll and reports in column V
        For i = 1 To LastRow
            If Cells(i, "I") = Cells(i + 1, "I") Then
                    sum = sum + Cells(i, "E").Value
            Else
                Cells(x, "V").Value = sum + Cells(i, "E").Value
                sum = 0
                x = x + 1
            End If
        Next i
    
    End Sub
    I'm getting a mismatch type error at these parts

        For i = 1 To LastRow
            Cells(i, "S").Value = Int(Cells(i, "K"))
            Cells(i, "T").Value = Cells(i, "K").Value - Cells(i, "S").Value
        Next i
            Else
                Cells(x, "V").Value = sum + Cells(i, "E").Value
                sum = 0
                x = x + 1
            End If
    Could it be that the Cells.Value data type doesn't match the Int() data type?
    In that case I don't know how to change either one of the data types.
    Any help would be much appreciated!
    Attached Files Attached Files
    Last edited by kelseygueldalewis; 04-06-2017 at 11:49 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Data Type mismatch error while using Like in access query
    By teco in forum Access Tables & Databases
    Replies: 5
    Last Post: 01-26-2017, 04:36 PM
  2. Data Type Mismatch Error on Open Recordset
    By masouder in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-15-2016, 11:56 AM
  3. Type Mismatch Error in Data Entry Form
    By sj9ers in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-01-2016, 12:43 PM
  4. type mismatch Error when writing data to excel
    By svibuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2013, 07:07 AM
  5. Type Mismatch Error on Large Data Sets
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2010, 04:40 PM
  6. [SOLVED] type mismatch error-copies data from one sheet to another
    By Marcotte A in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2005, 10:25 PM
  7. Type Mismatch Error when getting data from another workbook
    By Tony Zappal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2005, 07:06 PM

Tags for this Thread

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