Duplicate to many sheets and Multi selections Please help

abbas50

Board Regular
Joined
Dec 6, 2019
Messages
51
Office Version
  1. 2016
Platform
  1. Windows
What i am trying to achieve Textbox9 should run all previous data entry on userform and prevent duplicates and how can i do multi selections on combobox :/ to same cell seperated by comma please i need help :(



VBA Code:
Private Sub CommandButton1_Click()
Dim cNum As Integer
Dim X As Integer
Dim nextrow As Range
Dim sht As String
'set the variable for the sheet
sht = ComboBox1.Value
'check for values
If Me.ComboBox1.Value = "" Then
MsgBox "Select a sheet from the combobox and add the date"
Exit Sub
End If
'change the number for the number of controls on the userform
cNum = 15
'add the data to the selected worksheet
Set nextrow = Sheets(sht).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
For X = 1 To cNum
nextrow = Me.Controls("TextBox" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear the values in the userform
For X = 1 To cNum
Me.Controls("TextBox" & X).Value = ""
Next
'communicate the results
MsgBox "The values have been sent to the " & sht & " sheet"

lstdisplay.ColumnCount = 10
lstdisplay.RowSource = "A1:O200000"

End Sub

Private Sub CommandButton2_Click()
Unload UserForm1

End Sub
Private Sub TextBox10_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
 Select Case KeyAscii
        Case vbKey0 To vbKey9, vbKeyBack, vbKeyClear, vbKeyDelete, _
        vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown, vbKeyTab
            If KeyAscii = 46 Then If InStr(1, TextBox10.Text, ".") Then KeyAscii = 0
        Case Else
            KeyAscii = 0
            Beep
    End Select
End Sub

Private Sub TextBox4_AfterUpdate()
If Me.TextBox4.Value = _
     Replace(Me.TextBox4.Value, "@", "") Then
   MsgBox "Please enter a valid email address"
  
End If
End Sub




Private Sub TextBox6_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
        Case vbKey0 To vbKey9, vbKeyBack, vbKeyClear, vbKeyDelete, _
        vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown, vbKeyTab
            If KeyAscii = 46 Then If InStr(1, TextBox6.Text, ".") Then KeyAscii = 0
        Case Else
            KeyAscii = 0
            Beep
    End Select
End Sub


Private Sub TextBox9_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
        Case vbKey0 To vbKey9, vbKeyBack, vbKeyClear, vbKeyDelete, _
        vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown, vbKeyTab
            If KeyAscii = 46 Then If InStr(1, TextBox9.Text, ".") Then KeyAscii = 0
        Case Else
            KeyAscii = 0
            Beep
    End Select
End Sub

Private Sub UserForm_Initialize()
'dim the variables
Dim ws As Worksheet
'loop through worksheets
For Each ws In Worksheets
'use the code name in case sheet name changes
Select Case ws.CodeName
'exclude these sheets by code name
Case "Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6", "Sheet7", "Sheet8"
'Add the rest
Case Else
Me.ComboBox1.AddItem "UAE"
Me.ComboBox1.AddItem "KSA"
Me.ComboBox1.AddItem "Bahrain"
Me.ComboBox1.AddItem "Kuwait"
Me.ComboBox1.AddItem "Oman"
Me.ComboBox1.AddItem "Qatar"
Me.ComboBox1.AddItem "Jordan"
Me.ComboBox1.AddItem "Egypt"

End Select
Next ws

With TextBox3
.AddItem "Art"
.AddItem "Adventure"
.AddItem "Automotive"
.AddItem "Banking & Finance"
.AddItem "Beauty"
.AddItem "Business"
.AddItem "Creativity & Design"
.AddItem "Education"
.AddItem "Entertainment"
.AddItem "Events & Activities"
.AddItem "Fashion"
.AddItem "Food & Beverages"
.AddItem "Healthcare & Wellness"
.AddItem "Hospitality"
.AddItem "Lifestyle"
.AddItem "Luxury"
.AddItem "MakeUp"
.AddItem "Media"
.AddItem "Motivational"
.AddItem "Music"
.AddItem "Parenting"
.AddItem "Pets & Animals"
.AddItem "Photography"
.AddItem "Politics"
.AddItem "Real Estate"
.AddItem "Retail & Shopping"
.AddItem "Sports & Finess"
.AddItem "Style & Grooming"
.AddItem "Technology"
.AddItem "Travel & Tourism"
.AddItem "Videography"
End With

With TextBox2
.AddItem "Male"
.AddItem "Female"
.AddItem "Page"
End With

With TextBox12
.AddItem "Instagram"
.AddItem "Youtube"
.AddItem "Twitter"
End With

With TextBox14
.AddItem "1K - 10K"
.AddItem "10K - 50K"
.AddItem "50K - 100K"
.AddItem "100K - 500K"
.AddItem "500K - 1M"
.AddItem "1M - 5M"
.AddItem ">5M"
End With

With TextBox15
.AddItem "<0.5"
.AddItem "0.5 - 1.5"
.AddItem "1.5 - 3.0"
.AddItem "3.0 - 5.0"
.AddItem "5.0 - 10.0"
.AddItem ">10.0"
End With



End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,223,867
Messages
6,175,074
Members
452,611
Latest member
bls2024

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