View Full Version : Upon returning research userform,date is reversed MM/dd/yyyy(I.need.DD/mm/yyyy
Helow
I'm trying to fix a visual error date when a search is done on the UserForm.
when typing in textbox called "TB6" a date (06/08/2011), and then type in the textbox called "tb3" name (Ines Raquel Oliveira Reis Leorne)
By pushing the button called "PROC3" in the dataretornada "TB6" is (08/06/2011), but the spreadsheet is (06/08/2011).
pon returning research userform,the date is reversed MM/dd/yyyy (I.need.DD/mm/yyyy)
Name
Ines Raquel Oliveira Reis Leorne
Date in sheet
06/08/2011
--Propeties--
Label
TextBox
Data de Admissão
Name
"tb6"
Nome
"tb3"
Button
Label
Nome
Name
"PROC3"
Greetings and Welcome to vbaexpress elsq, :hi:
You have a lot of code in your wb and no indenting, which in my humble opinion, makes it more difficult to read. That said, I put breaks on most every line with 'tb6' (TextBox control) and found that it did reformat the string (not a true date) ending up in the textbox, here:
Private Sub PROC3_Click()
Dim c As Range
Dim LINHA
Dim ws As Worksheet
On Error Resume Next
ComboBox1.Value = ""
'Verificar se foi digitado um nome na primeira caixa de texto
If tb3.Text = "" Then
MsgBox "Digite o Nome do Jovem!"
tb3.SetFocus
GoTo Linha1
End If
For Each ws In Worksheets
Set c = ws.Range("C:C").Find(tb3.Value, LookIn:=xlValues, _
LookAt:=xlWhole)
If Not c Is Nothing Then
c.Activate
tb3.Value = c.Value
tb1.Value = c.Offset(0, -2).Value
tb2.Value = c.Offset(0, -1).Value
If c.Offset(0, 56).Value = "S" Then
op1.Value = True
Else
op1.Value = False
End If
tb6 = Format(tb6.Value, "dd-mm-yyyy")
tb6.Value = c.Offset(0, 1).Value
'...remainder of code...
That is not saying much though, as my system expects U.S. style dates (mm/dd/yyyy). I am guessing that your computer defaults to dd/mm/yyyy?
Anyways, for what it is worth, it is what Excel and/or the OS expects, not what is in a textbox (which is only a String) that counts. When you take the value of the textbox (to a worksheet), I suspect that is where you will want stop and coerce an actual date (before plunking the value on a sheet).
You might wish to consider three combo boxes instead of one textbox. That way you can have only acceptable values being considered.
Hope that helps a tiny bit at least,
Mark
If you want to write the first of may into a cell in a worksheet you wil have to use either:
cells(1,1)=cdate("01-05-2013")
or
cells(1,1)=datevalue("01-05-2013")
or
cells(1,1)=format("01-05-2013","yyyy-mm-dd")
Forgive me guys, because I do not know English and not VBA, I'll have to try to change my routines.
so I'll give up this topic.
thank you!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.