• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

to come cell value in textbox as it is

ajaar

Member
HI Friends,

We do restrict the textbox to accept only text or date...etc. my case is different, i wanted to come cell value in the textbox as it is. I have below code to bring the lookup value in the textbox, some time value will be date and time, some time it is text.
alofr is the name of text box. arrno is the value in the compobox,.

Appreciate your help
Code:
Private Sub arrno_Change
alofr.Value = Application.VLookup(Val(arrno.Value), Sheets("Data").Range("f3:ab25000"), 4, False)
End sub
 
Hi,

You can store the lookup value in one variable (to avoid multiple times lookup function) and check if its a date, if yes apply the formatting and if not show as it is.

see below code:

Code:
  If VBA.IsDate(Range("A1").Value) Then
  TextBox1.Value = VBA.Format(Range("A1").Value, "dd-mm-yyyy")
  Else
  TextBox1.Value = Range("A1").Value
  End If

regards,
Prasad DN
 
Back
Top