ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Morning.
I have Two codes where one needs to have some code added from the other code.
This is the code that needs the extra code adding to.
We shall call it CODE A
This is the code the extra code needs to be copied from.
We shall call it CODE B
So in CODE B when the code runs it checks in the column G
Depending on the situation in column G then the userform is shown or i see the msgBox NO NAMES TO SHOW blah blah blah
With CODE A the customer is selected from the ComboBox, then the command button adds a date on the worksheet where previously the cell was RED & had the text POSTED in it.
Once the last name has been completed i should then see the MsgBox advising me NO NAMES TO SHOW blah blah blah.
Many thanks
I have Two codes where one needs to have some code added from the other code.
This is the code that needs the extra code adding to.
We shall call it CODE A
VBA 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") <> "" 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"
UserForm_Initialize
End If
End If
NameForDateEntryBox = ""
TextBox7 = ""
TextBox7.Value = Format(CDbl(Date), "dd/mm/yyyy")
End Sub
This is the code the extra code needs to be copied from.
We shall call it CODE B
Code:
Private Sub Openuserform_Click()
Dim ws As Worksheet
Set ws = Sheets("POSTAGE")
Dim FirstRow As Long, LastRow As Long
Static FirstTime As Boolean, fCell As Range
If FirstTime = False Then Set fCell = ws.Range("G:G").Find(What:="POSTED", After:=ws.Range("G1"), LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
If Not fCell Is Nothing Then
FirstTime = True
FirstRow = fCell.Row
LastRow = ws.Cells(Rows.Count, 7).End(xlUp).Row
Do Until FirstRow > LastRow
If ws.Range("G" & FirstRow).Interior.Color = RGB(255, 0, 0) And ws.Range("G" & FirstRow).Value = "POSTED" Then
PostageTransferSheet.Show
Exit Sub
End If
FirstRow = FirstRow + 1
Loop
End If
MsgBox "NO NAMES TO SHOW AS ALL PARCELS HAVE NOW BEEN DELIVERED", vbInformation, "POSTAGE DATE TRANSFER SHEET MESSAGE"
FirstTime = False
Set fCell = Nothing
End Sub
So in CODE B when the code runs it checks in the column G
Depending on the situation in column G then the userform is shown or i see the msgBox NO NAMES TO SHOW blah blah blah
With CODE A the customer is selected from the ComboBox, then the command button adds a date on the worksheet where previously the cell was RED & had the text POSTED in it.
Once the last name has been completed i should then see the MsgBox advising me NO NAMES TO SHOW blah blah blah.
Many thanks