lucpian

02-08-2008, 08:28 AM

Hi,

I have jus written a code to validate the entries in column C in my worksheet which should be either Y or M. Below is the code I wrote, but I keep having error. Please, can someone help me out.

Function MaintenanceFreqChecking(columnname As Integer)

Dim rowcount

Dim R

Dim Y As String

Dim M As String

rowcount = Range("A65536").End(xlUp).Row

For R = 2 To rowcount

strVal = Sheet1.Cells(R, columnname).Value

If strVal <> "Y" Or strVal <> "M" Then

Sheet1.Cells(R, columnname).Interior.ColorIndex = 6

End If

Next

End Function

Thanks

Lucpian

I have jus written a code to validate the entries in column C in my worksheet which should be either Y or M. Below is the code I wrote, but I keep having error. Please, can someone help me out.

Function MaintenanceFreqChecking(columnname As Integer)

Dim rowcount

Dim R

Dim Y As String

Dim M As String

rowcount = Range("A65536").End(xlUp).Row

For R = 2 To rowcount

strVal = Sheet1.Cells(R, columnname).Value

If strVal <> "Y" Or strVal <> "M" Then

Sheet1.Cells(R, columnname).Interior.ColorIndex = 6

End If

Next

End Function

Thanks

Lucpian