how change code from range to Table when copy from userform to Table

Maklil

Board Regular
Joined
Jun 23, 2022
Messages
144
Office Version
  1. 2019
Platform
  1. Windows
Hi experts ,
I look for converting this code when copying from range to TABLE . the code will copy into two columns A,B based on selected optionbutton .
now I created TABLE1 for column A , TABLE2 for column B . so when select optionbutton1 and fill textbox1, then should copy in TABLE1(column A) , when select optionbutton2 and fill textbox1, then should copy in TABLE2(column B), when copying should be to the bottom .
here is the code I work on it.
VBA Code:
Private Sub CommandButton1_Click()
Dim lr, lr1 As Long
Dim ws As Worksheet
Set ws = Sheets("sheet1")
lr = ws.Range("A" & Rows.Count).End(xlUp).Row
lr1 = ws.Range("B" & Rows.Count).End(xlUp).Row
With ws
If OptionButton1.Value = True Then Range("A" & lr + 1) = TextBox1.Value
If OptionButton2.Value = True Then Range("B" & lr1 + 1) = TextBox1.Value
End With
End Sub
thanks in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,215,092
Messages
6,123,064
Members
449,090
Latest member
fragment

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