Show text in worksheet cell advising user to enter the relevant text here

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,731
Office Version
  1. 2007
Platform
  1. Windows
On my worksheet in cell G39 i wish for the user to type the relevant text in that cell.
Can we put a faded text in that cells to advise user where its to be placed.

Example cell G39 shows PIN CODE HERE.
User would then type 123456 in the cell & PIN CODE HERE would be overwritten or removed until next time.

I dont want to use a label etc so is this possible please


I had seen this code / short video clip which is what i require but its for a TextBox

VBA Code:
Private Sub TextBox2_Change()
    TextBox2.BackStyle = IIf(Len(TextBox2.Text) = 0, fmBackStyleTransparent, fmBackStyleOpaque)
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
if you use a worksheet event to replace the value and formating of that cell everytime it changes to empty would do the trick

then another event that replace the format to standard when someone types something there
 
Upvote 0
@ipbr21054

Give this a try. Paste code into the code module of the sheet concerned.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("G39")) Is Nothing Then Exit Sub
Dim Rng As Range
Set Rng = Range("G39")
Application.EnableEvents = False
If IsNumeric(Trim(Rng)) Then
Rng.Font.ColorIndex = -4105
Else
Rng = "PIN CODE HERE"
    Rng.Font.ColorIndex = 15
End If
Application.EnableEvents = True
End Sub
HTH
 
Upvote 0
Solution
Hi,
I have a change event allready so my code is now as supplied.
I do not see anything in cell G39


Also how would i change so i could use hex code for the color
Do you see an issue with the code ?

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.count > 1 Or Target.HasFormula Then Exit Sub
    If Not Intersect(Target, Range("L14:L18,G13:G18,G27:M51")) Is Nothing Then
        Application.EnableEvents = False
        Target = UCase(Target)
        Application.EnableEvents = True
    End If
    If Not Intersect(Target, Range("G13")) Is Nothing Then
        Range("G1").Select
    End If


If Intersect(Target, Range("G39")) Is Nothing Then Exit Sub
Dim Rng As Range
Set Rng = Range("G39")
Application.EnableEvents = False
If IsNumeric(Trim(Rng)) Then
Rng.Font.ColorIndex = -4105
Else
Rng = "PIN CODE HERE"
    Rng.Font.ColorIndex = 15
End If
Application.EnableEvents = True

End Sub
 
Upvote 0
I have removed the existing code & tried it with only your code but made no difference.

I have also tried it on another sheet & the same.
 
Last edited:
Upvote 0
I have removed the existing code & tried it with only your code but made no difference.

I have also tried it on another sheet & the same.
It appears to work fine for me.
Have you, while testing, had it error or quit without 'Application.EnableEvents = False" having been reestablished a True ?
Try Application.EnableEvents = True in the immediate pane and hit return.
 
Upvote 0
No errors or anything.
If it helps i dont even see the text in the cell its supposed to be shown in.

true also made no difference

I opened a new woorkbook / worksheet & still i see no text in the cell
 
Upvote 0
What is the name of the VBA module where you placed that "Worksheet_Change" code?
 
Upvote 0
I right clicked on the INV worksheet then placed it in the change event
Reading original post it shows code module,is that then right click & paste ?
 
Upvote 0
Should it go here ?

If so how does it know to run on sheet INV

EaseUS_2024_08_23_14_21_15.jpg
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top