Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Changing case and also changing entered data

I have a sheet that in column D I will be entering a value of "p" or "f". I
would like code behind the scenes checking column D for a "p" or "f" as well
as "P" or "F" and changing that "p" or "f" to "Pass" or "Fail". Now I also
have some on change code already looking at that cell so I need this code to
append to that code. Here is the code I already have:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
Dim myR As Long

If Target.Cells.Count 1 Then Exit Sub
If Target.Column < 4 Then Exit Sub
If UCase(Target.Value) < "FAIL" Then Exit Sub

Application.EnableEvents = False
myR = Sheets("Notes").Cells(Rows.Count, 4).End(xlUp).Row
Target.EntireRow.Copy Sheets("Notes").Cells(myR + 1, 1).EntireRow
If Target.EntireRow.Cells(1, 1).Value = "" Then
Worksheets("Notes").Range("A" & myR + 1).Value = _
Target.EntireRow.Cells(1, 1).End(xlUp).Value
Else
Worksheets("Notes").Range("A" & myR + 1).Value = _
Target.EntireRow.Cells(1, 1).Value
End If
Sheets("Notes").Cells(myR + 1, 1).Resize(1, 7).Interior.ColorIndex _
= Target.Interior.ColorIndex
Sheets("Notes").Cells(myR + 1, 1).Resize(1, 8).Interior.ColorIndex _
= Target.Interior.ColorIndex

Sheets("Notes").Cells(myR + 1, 7).BorderAround xlContinuous, xlThin
Sheets("Notes").Cells(myR + 1, 8).BorderAround xlContinuous, xlThin

Adden = "Notes!H" & myR
ActiveSheet.Hyperlinks.Add Anchor:=Target, _
Address:="", SubAddress:=Adden, _
TextToDisplay:="Fail"
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Changing case and also changing entered data

You probably want this just after your Dim statements since you have one
that exits the sub if the target equals "FAIL".

If LCase(Target.Value) = "p" Then
Target.Value = "Pass"
ElseIf LCase(Target.Value) = "f" Then
Target.Value = "Fail"
End If


"hshayh0rn" wrote in message
...
I have a sheet that in column D I will be entering a value of "p" or "f". I
would like code behind the scenes checking column D for a "p" or "f" as
well
as "P" or "F" and changing that "p" or "f" to "Pass" or "Fail". Now I also
have some on change code already looking at that cell so I need this code
to
append to that code. Here is the code I already have:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
Dim myR As Long

If Target.Cells.Count 1 Then Exit Sub
If Target.Column < 4 Then Exit Sub
If UCase(Target.Value) < "FAIL" Then Exit Sub

Application.EnableEvents = False
myR = Sheets("Notes").Cells(Rows.Count, 4).End(xlUp).Row
Target.EntireRow.Copy Sheets("Notes").Cells(myR + 1, 1).EntireRow
If Target.EntireRow.Cells(1, 1).Value = "" Then
Worksheets("Notes").Range("A" & myR + 1).Value = _
Target.EntireRow.Cells(1, 1).End(xlUp).Value
Else
Worksheets("Notes").Range("A" & myR + 1).Value = _
Target.EntireRow.Cells(1, 1).Value
End If
Sheets("Notes").Cells(myR + 1, 1).Resize(1, 7).Interior.ColorIndex _
= Target.Interior.ColorIndex
Sheets("Notes").Cells(myR + 1, 1).Resize(1, 8).Interior.ColorIndex _
= Target.Interior.ColorIndex

Sheets("Notes").Cells(myR + 1, 7).BorderAround xlContinuous, xlThin
Sheets("Notes").Cells(myR + 1, 8).BorderAround xlContinuous, xlThin

Adden = "Notes!H" & myR
ActiveSheet.Hyperlinks.Add Anchor:=Target, _
Address:="", SubAddress:=Adden, _
TextToDisplay:="Fail"
Application.EnableEvents = True
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing from lower case to upper case Hok Wong[_2_] Excel Discussion (Misc queries) 11 December 8th 09 02:30 AM
Changing Fill Color When Data is Entered Julia1727 Excel Discussion (Misc queries) 1 January 23rd 08 02:10 AM
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
Changing the case of text data fuzzyjon Excel Worksheet Functions 4 May 15th 06 04:50 PM
changing lower case to upper case T. Campbell Excel Discussion (Misc queries) 1 December 8th 04 05:37 PM


All times are GMT +1. The time now is 04:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"