• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to check the years of service

baba_excel

New Member
Greetings


Problem: From database student data would be pulled as follows:


09/05/2005 - 10/15/2006 - A

10/15/2006 - 12/31/2006 - O

01/01/2007 - 02/29/2010 - A

03/01/2010 - 12/31/2011 - O

01/01/2012 - F


So the period pulled in excel can be in more than 5 rows and there certain conditions governing it


so if O < 6 then prior A is F and if > 6 then prior A = O (2007 - 2011)


wrote the code but looks like it will not solving the purpose


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 = "O" 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


knew there are updates but guidance would help
 
Hi ,


The first step towards solving any problem is to precisely and clearly define it ; your data is not very clear , and I think you should not expect others to go through your code to understand what you want.


Is it possible you can first explicitly state what your data is ( what are the A , O and F ? ) , and what is the significance of the 5 rows ?


Narayan
 
Back
Top