ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,731
- Office Version
- 2007
- Platform
- Windows
Hi,
The code in use is shown below.
This is how it works.
I have a listbox with customers names.
I select a name & when i press the DateTransferButton todays date then is entered into the cell for this customer at colomn G
I believe at present if a value is in the G cell then i see a message DATE HAS BEEN ENTERED ALREADY
The edit i require is to only show the message if a date is present in the cell, should the word POSTED be in the cell then allow it to continue & dont show me the message
The code in use is shown below.
This is how it works.
I have a listbox with customers names.
I select a name & when i press the DateTransferButton todays date then is entered into the cell for this customer at colomn G
I believe at present if a value is in the G cell then i see a message DATE HAS BEEN ENTERED ALREADY
The edit i require is to only show the message if a date is present in the cell, should the word POSTED be in the cell then allow it to continue & dont show me the message
Code:
Private Sub DateTransferButton_Click()
'Dantes code
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").Value <> "" 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