Default first two characters of cell input

mr.bonligur

New Member
Joined
Jun 30, 2011
Messages
3
hi,, im sorry for interrupting. im a newbie here. how can i post?:confused:


hi..;) how cud i pre input two characters in default without typing it. im encoding code having the same first two letters as "BH" because we are using those codes. e.g. BHUN BHGY BHFD BHAA BHEE BHFD some what like that. im thinking it wud be more easy if i'l type letters UN only instead of BHUN, GY instead of BHGY and so on..

hope u can help me with this one. im from the philippines.:biggrin:
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
How about this:

(Alt+F11, then double click on Sheet1 and copy the text into the editor.)

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.Value, 2) <> "BH" Then Target.Value = "BH" & Target.Value
End Sub

It will prefix your text with BH for any cell you change in the sheet, so be careful with that. I'm sure you'll need to finetune it for your needs.
 
Upvote 0
BarCodeWiz, what for is this checking?
If Left(Target.Value, 2) <> "BH"
 
Upvote 0
And what if I want to be in a cell BHBH?
To prevent infinite loop:
Code:
[COLOR="Blue"]Private[/COLOR] [COLOR="Blue"]Sub[/COLOR] Worksheet_Change([COLOR="Blue"]ByVal[/COLOR] Target [COLOR="Blue"]As[/COLOR] Range)
    Application.EnableEvents = [COLOR="Blue"]False[/COLOR]
        Target.Value = "BH" & Target.Value
    Application.EnableEvents = [COLOR="Blue"]True[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
And what if I want BHBH to be in a cell?
 
Upvote 0
Cool solution taking into account mr.bonligur's request to enter only two letters.
Great! :biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,254
Members
452,900
Latest member
LisaGo

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