Advice for two opertion selection before transfer to worksheet

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Afternoon,

I have a userform which has textboxes etc where i add values then these are transfered to the worksheet.
I have two ComboBoxes on the form.

1 x NameForDateEntryBox has customers names of which i select from the list.

1 x PostageIssueBox has a few words of which i also select from,these are populated from Table34

I have a command button for which i need to apply code to.
The name of the command button is PostageIssueButton

This is what the command button should do.
Look at customers name from NameForDateEntryBox
Look at word from PostageIssueBox

Worksheet is called POSTAGE
Customers name will be in column B
Once customer has been found enter the word taken from PostageIssueBox & put it in column G for the customer in question.

If its any use & to save you time i already have something that pretty much does this BUT you will need to add the piece of code for looking at the value in PostageIssueBox

Rich (BB 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 The Date 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 "DATE APPLIED TO WORKSHEET FOR " & NameForDateEntryBox.Value, vbInformation, "DELIVERY PARCEL DATE TRANSFER MESSAGE"
                    NameForDateEntryBox.Clear
                    UserForm_Initialize
                    
                End If
            End If
            NameForDateEntryBox = ""
            TextBox7 = ""
            TextBox7.Value = Format(CDbl(Date), "dd/mm/yyyy")
        End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
So ive had a go myself & come up with the below.

Rich (BB code):
            Private Sub PostageIssueButton_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 The Pressing Transfer Button", vbCritical, "POSTAGE ISSUE MESSAGE"
                Exit Sub
            End If
                        
            wName = NameForDateEntryBox.List(NameForDateEntryBox.ListIndex)
            wName = PostageIssueBox.List(PostageIssueBox.ListIndex)
            Set sh = Sheets("POSTAGE")
            Set b = sh.Columns("B").Find(wName, LookIn:=xlValues, LookAt:=xlWhole)
            If Not b Is Nothing Then
                    
                    sh.Cells(b.Row, "G").Value = PostageIssueBox.Value
                    sh.Cells(b.Row, "G").Interior.Color = vbYellow
                    MsgBox "POSTAGE ISSUE APPLIED TO WORKSHEET FOR " & NameForDateEntryBox.Value, vbInformation, "POSTAGE ISSUE MESSAGE"
                    NameForDateEntryBox.Clear
                    UserForm_Initialize
                    
                End If
            
            
            End Sub

I select a name from NameForDateEntryBox & also a word from PostageIssueBox
I then press the command button called PostageIssueButton

But as i expected nothing then happend not even a RTE
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

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