+ Reply to Thread
Results 1 to 3 of 3

TYPE MISMATCH ERROR ...... please help to correct my code ????????

  1. #1
    Registered User
    Join Date
    03-07-2012
    Location
    jaipur
    MS-Off Ver
    Excel 2007
    Posts
    50

    TYPE MISMATCH ERROR ...... please help to correct my code ????????

    Hi all i have below list of 3 agents whose name and codes are given in column A , i made a macro on basis of code "FLEXMI" it will subtract fourth cell(column E) of FLEXMI with 8th cell of shift (column I).
    step by step what code is doing
    1. the code is matching 'FLEXMI' at 'A3'
    2. then it does (I4 - E3)
    3. then puts the result of the subtraction above as the new value of the cell 'I4'

    PROBLEM is its only subtracting the first agent FLEXMI with his SHIFT TIME , rest two agents, its showing type mismatch error , because FLEXMI is given after SHIFT , or in the last , please correct my code ?????

    code:
    [p]Dim LR As Long, k As Long
    LR = Cells(Rows.Count, 1).End(xlUp).Row
    For k = 3 To LR
    If Cells(k, 1).Value = "FLEXMI" Then
    Cells(k, 1).Offset(1, 8).Value = Cells(k, 1).Offset(1, 8).Value - _
    Cells(k, 1).Offset(, 4).Value
    End If
    Next k
    [/p]

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: TYPE MISMATCH ERROR ...... please help to correct my code ????????

    The below code is causing the error. I believe either Cells(k, 1).Offset(1, 8).Value is having text data or this Cells(k, 1).Offset(, 4).Value

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    03-07-2012
    Location
    jaipur
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: TYPE MISMATCH ERROR ...... please help to correct my code ????????

    Nominal Date: 04/11/12
    Employee Group: OTHER
    Employee Name: Acharya, Anand (59828) Segment Code Starts Stops Duration
    FLEXMI 04/11/12 10:00 12:00 2:00
    SHIFT 04/11/12 10:00 18:00 8:00 7:30 Employee Name: Acharya, Anand (59828) 5:30 59828
    REFGEN 04/11/12 10:00 18:00 8:00
    BREAK1 04/11/12 14:15 14:35 0:20
    LUNCH 04/11/12 16:00 16:30 0:30
    BREAK2 04/11/12 17:00 17:10 0:10

    Employee Name: Anwar Ul Haque, Parvez (59267) Segment Code Starts Stops Duration
    REFGEN 04/11/12 10:00 18:00 8:00
    SHIFT 04/11/12 10:00 18:00 8:00 7:30 Employee Name: Anwar Ul Haque, Parvez (59267) 7:30 59267
    BREAK1 04/11/12 13:00 13:20 0:20
    FLEXMI 04/11/12 10:00 12:00 2:00
    LUNCH 04/11/12 15:30 16:00 0:30
    BREAK2 04/11/12 17:00 17:10 0:10

    Employee Name: Babu, Sabu P (59501) Segment Code Starts Stops Duration
    SHIFT 04/11/12 10:00 17:00 7:00 6:30 Employee Name: Babu, Sabu P (59501) 7:00 59501
    REFGEN 04/11/12 10:00 17:00 7:00
    FLEXMI 04/11/12 10:00 12:00 2:00

+ 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