+ Reply to Thread
Results 1 to 11 of 11

Need a vba code to check the status and based on rules calculate service years

Hybrid View

  1. #1
    Registered User
    Join Date
    06-12-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Need a vba code to check the status and based on rules calculate service years

    vba_code_3.xlsm‎ is attached in post#1, this is updated where in checking step by step the code was running with msg box displaying 2 ans but at my home system it is giving errors first one being "Invalid qualifier".
    Any suggestions or updates are much appreciated.

  2. #2
    Registered User
    Join Date
    06-12-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Need a vba code to check the status and based on rules calculate service years

    Greetings .....
    was able to overcome the error ...needed to do x = instead x.
    Please see the update ....also moving with same is there a way to check the previous value for cell c.
    i.e in if condition c is checked for LOA now if it is true and >1 then prior ACT period gets added.

    Overall goal is to insert data into sheets from database which may have multiple statuses for same hence think need to update the code me trying the same but inputs would be much appreciated



    Sub test()
    
    Dim x As Integer
    Range("b2").Select
    'Cells(65536, 2).End(xlUp).Select
    x = ActiveCell.Row
       
    For i = 2 To x
    If Range("c" & i).Value = "LOA" And Format(Range("b" & i).Value - Range("a" & i).Value, "m") > 6 Then
    MsgBox Format(Range("b" & i).Value - Range("a" & i).Value, "m")
    End If
    Next i
    End Sub

  3. #3
    Registered User
    Join Date
    06-12-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Need a vba code to check the status and based on rules calculate service years

    Greetings .....
    was able to overcome the error ...needed to do x = instead x.
    Please see the update ....also moving with same is there a way to check the previous value for cell c.
    i.e in if condition c is checked for LOA now if it is true and >1 then prior ACT period gets added.

    Overall goal is to insert data into sheets from database which may have multiple statuses for same hence think need to update the code me trying the same but inputs would be much appreciated



    Sub test()
    
    Dim x As Integer
    Range("b2").Select
    'Cells(65536, 2).End(xlUp).Select
    x = ActiveCell.Row
       
    For i = 2 To x
    If Range("c" & i).Value = "LOA" And Format(Range("b" & i).Value - Range("a" & i).Value, "m") > 6 Then
    MsgBox Format(Range("b" & i).Value - Range("a" & i).Value, "m")
    End If
    Next i
    End Sub

+ 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