PDA

View Full Version : Code for changing an entry to uppercase



lucpian
03-27-2008, 11:24 AM
Hello,

I am new to this forum and I am trying my luck because my colleague at work talks so good of how this forum is and has been very useful to him. I have a vba code which I am writing to change whatever entry to uppercase, but it should use an array. I am a complete novice as long as vba is concern. I did put up the following code, and it is not working . I want the code to check if the values is D or G, and if it is not an uppercase D or G it should color it blue. That is too much of a homework.


Function MainteFreq(columnname As Integer)
Dim rowcount
Dim R
rowcount = Range("A65536").End(xlUp).Row
For R = 2 To rowcount
strVal = Sheet1.Cells(R, columnname).Value
'Sheet1.Cells(R, columnname).Value = strVal
If strVal = "y" Or strVal = "m" Then
strVal = UCase(strVal)

End If

Next
End Function

Please, someone help me out.

Thanks

MariaFunsho

Bob Phillips
03-27-2008, 11:28 AM
Is this what You mean?



Function MainteFreq(columnname As Integer)
Dim rowcount
Dim R
rowcount = Range("A65536").End(xlUp).Row
For R = 2 To rowcount

strVal = Sheet1.Cells(R, columnname).Value
'Sheet1.Cells(R, columnname).Value = strVal
If Application.exact(strVal, "D") Or Application.exact(strVal, "G") Then

Sheet1.Cells(R, columnname).Interior.ColorIndex = 5
End If
Next
End Function

lucpian
03-27-2008, 11:38 AM
Hello xld,

Like I said I am very new to vba and is still learning. Does this code check to see if the entries are uppercase or not.

Thanks

MariaFunsho

mdmackillop
03-27-2008, 12:31 PM
It does. You should look at Exact in Excel (not VBA) Help.