ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Hi,
Please see the code in use.
On my worksheet i select a name from textbox called NameForDateEntryBox
I then press the command button called DateTransferButton
What this does is put todays date against the customer selected on the worksheet.
This all works fine BUT when i first started this something wasnt working correct.
The part of the code in question is after i press the command button the userform closes then opens again.
From memory if i didnt had it close/open i couldnt get it to work.
Can you see a way to allow the date to be just entered without the need for the userform to close / open every time.
Please see the code in use.
On my worksheet i select a name from textbox called NameForDateEntryBox
I then press the command button called DateTransferButton
What this does is put todays date against the customer selected on the worksheet.
This all works fine BUT when i first started this something wasnt working correct.
The part of the code in question is after i press the command button the userform closes then opens again.
From memory if i didnt had it close/open i couldnt get it to work.
Can you see a way to allow the date to be just entered without the need for the userform to close / open every time.
Rich (BB code):
Private Sub DateTransferButton_Click()
Dim sh As Worksheet
Dim b As Range
Dim wName As String, res As Variant
If NameForDateEntryBox.ListIndex = -1 Then
MsgBox "Please Select A Customer Before Transfer Button", vbCritical, "Delivery Parcel Date Transfer"
Exit Sub
End If
If TextBox7.Value = "" Or Not IsDate(TextBox7.Value) Then
MsgBox "Please Enter A Valid Date", vbCritical, "Delivery Parcel Date Transfer"
TextBox7 = ""
TextBox7.SetFocus
Exit Sub
End If
wName = NameForDateEntryBox.List(NameForDateEntryBox.ListIndex)
Set sh = Sheets("POSTAGE")
Set b = sh.Columns("B").Find(wName, LookIn:=xlValues, lookat:=xlWhole)
If Not b Is Nothing Then
If sh.Cells(b.Row, "G") <> "" And UCase(sh.Cells(b.Row, "G")) <> "POSTED" Then
MsgBox "DATE HAS BEEN ENTERED ALREADY !" & vbCrLf & "CLICK OK TO GO CHECK IT OUT", vbCritical, "Delivery Parcel Date Transfer"
TextBox7 = ""
Unload PostageTransferSheet
Cells(b.Row, "G").Select
Else
sh.Cells(b.Row, "G").Value = CDate(TextBox7.Value)
sh.Cells(b.Row, "G").Interior.Color = vbYellow
MsgBox "DELIVERY DATE NOW APPLIED TO WORKSHEET", vbInformation, "DELIVERY PARCEL DATE TRANSFER MESSAGE"
Unload PostageTransferSheet
PostageTransferSheet.Show
End If
End If
NameForDateEntryBox = ""
TextBox7 = ""
TextBox7.Value = Format(CDbl(Date), "dd/mm/yyyy")
End Sub