Trouble With Dates!

longytravel

Board Regular
Joined
Aug 2, 2011
Messages
68
Afternoon,

As ever help would be greatly recieved!

I have this code from one of my userforms. It populates the detail from the form onto a sheet.

The code at the bottom populates me the date in the relevant text box. It shows in the format of dd.mm.yy which is what i am after as an end result.

when it imports it into the document it changes it to mm.dd.yy.

I've played around with the formatting but no joy

Any ideas?

Thanks

Code:
Private Sub CommandButton1_Click()
Me.ComboBox2.Value = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.ComboBox4.Value = ""
Me.ComboBox5.Value = ""
Me.ComboBox2.SetFocus
End Sub
Private Sub CommandButton2_Click()
Dim eRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
'find first empty row in database
eRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'check for a name
If Trim(Me.ComboBox2.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Please Enter A Project"
Exit Sub
End If
'copy the data to the database
ws.Cells(eRow, 1).Value = Me.ComboBox2.Value
ws.Cells(eRow, 2).Value = Me.TextBox6.Value
ws.Cells(eRow, 3).Value = Me.TextBox1.Value
ws.Cells(eRow, 4).Value = Me.TextBox2.Value
ws.Cells(eRow, 5).Value = Me.TextBox3.Value
ws.Cells(eRow, 6).Value = Me.TextBox4.Value
ws.Cells(eRow, 7).Value = Me.TextBox5.Value
ws.Cells(eRow, 8).Value = Me.ComboBox4.Value
ws.Cells(eRow, 9).Value = Me.ComboBox5.Value
 
'clear the data
Me.ComboBox2.Value = ""
Me.TextBox6.Value = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.ComboBox4.Value = ""
Me.ComboBox5.Value = ""
Me.ComboBox2.SetFocus
 
MsgBox "Thank You!  Your Update Has Been Saved!", vbInformation + vbOKOnly, "Update Complete"
ActiveWorkbook.Close True
End Sub
Private Sub CommandButton3_Click()
Application.Visible = True
UserForm1.Hide
Dim t_Range As Excel.Range
Set t_Range = ActiveSheet.Range("Data")
'--- Could use any number of methods to get the range...
t_Range.Borders(xlDiagonalDown).LineStyle = xlNone
t_Range.Borders(xlDiagonalUp).LineStyle = xlNone
With t_Range.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With
With t_Range.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With
With t_Range.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With
With t_Range.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With
t_Range.Borders(xlInsideVertical).Weight = xlThin
t_Range.Borders(xlInsideHorizontal).Weight = xlThin
 
End Sub
 
 
Private Sub TextBox6_Change()
End Sub
Private Sub UserForm_Initialize()
   Me.TextBox6.Text = Date
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Code:
ws.Cells(eRow, 2).Value = Me.TextBox6.Value

This bit i think!!!!

THe key is to make sure as more entries are added they all follow after one another and not write over each other

Cheers
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,881
Members
452,948
Latest member
Dupuhini

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