PC Review


Reply
Thread Tools Rate Thread

Changing case and also changing entered data

 
 
hshayh0rn
Guest
Posts: n/a
 
      15th May 2009
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 With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      15th May 2009
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" <(E-Mail Removed)> wrote in message
news:87A017FC-A424-4135-B42B-(E-Mail Removed)...
>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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Fill Color When Data is Entered Julia1727 Microsoft Excel Misc 1 23rd Jan 2008 02:10 AM
Changing the case of text data fuzzyjon Microsoft Excel Worksheet Functions 4 15th May 2006 04:50 PM
Help with changing entered data =?Utf-8?B?U21hY2tib3k=?= Microsoft Excel Misc 3 27th Sep 2004 07:59 PM
Help with changing entered data =?Utf-8?B?U21hY2tib3k=?= Microsoft Excel New Users 4 27th Sep 2004 06:33 PM
Changing data from Upper Case to Mixed Case ray Microsoft Access Security 0 8th Jul 2003 09:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:11 PM.