Copy multiple activex control values to new ws

Chickenmanc

New Member
Joined
Mar 26, 2019
Messages
8
I am learning vba on my own and I found get helpful info from this forum so I joined. Thanks. I am trying to take 4 different combobox values, and 2 textbox values from one sheet and paste them in first empty row of another worksheet.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Welcome to the forum

Try this:

Code:
Sub Copy_multiple_activex()
    Dim sh1 As Object, sh2 As Worksheet
    Set sh1 = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]")  'Source
    Set sh2 = Sheets("[COLOR=#ff0000]Sheet2[/COLOR]")  'Destination
    
    If sh1.ComboBox1.Value = "" Then
        MsgBox "Fill combo 1"
        Exit Sub
    End If
    lr = sh2.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
    sh2.Cells(lr, "A").Value = sh1.ComboBox1.Value
    sh2.Cells(lr, "B").Value = sh1.ComboBox2.Value
    sh2.Cells(lr, "C").Value = sh1.ComboBox3.Value
    sh2.Cells(lr, "D").Value = sh1.ComboBox4.Value
    sh2.Cells(lr, "E").Value = sh1.TextBox1.Value
    sh2.Cells(lr, "F").Value = sh1.TextBox2.Value
End Sub
 
Last edited:
Upvote 0
change this
Code:
Set sh1 = Sheets("Sheet1")  'Source

For this
Code:
Set sh1 = Activesheet  'Source
 
Upvote 0
Thanks. I appreciate it. I feel like I am learning things but when you see different ways to perform the same code it gets confusing.
 
Upvote 0
I added a label as well. I used your code

Code:
ub Copy_multiple_activex()
    Dim sh1 As Object, sh2 As Worksheet
    Set sh1 = Sheets("Sheet1")  'Source
    Set sh2 = Sheets("Sheet2")  'Destination
    
    If sh1.ComboBox1.Value = "" Then
        MsgBox "Fill combo 1"
        Exit Sub
    End If
    lr = sh2.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
    sh2.Cells(lr, "A").Value = sh1.ComboBox1.Value
    sh2.Cells(lr, "B").Value = sh1.ComboBox2.Value
    sh2.Cells(lr, "C").Value = sh1.ComboBox3.Value
    sh2.Cells(lr, "D").Value = sh1.ComboBox4.Value
    sh2.Cells(lr, "E").Value = sh1.TextBox1.Value
    sh2.Cells(lr, "F").Value = sh1.TextBox2.Value
End Sub
[code]

I tried:
sh2.cells(lr, ”G”).value = sh1.cartnum.caption
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

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