Commandbutton to copy based on CheckBox True/False

TDNova

New Member
Joined
Apr 16, 2018
Messages
45
Hello, im trying to figure out how to make this work.

I got a table with informaton. with a checkbox on the side of the table.
simply explained:
When the checkbox on the row is true, copy table row "b3:p3" to a new table.
but i want it to be activated by a commandbutton, so i can choose 5 checkboxes before it starts to copy.

Is there a way for it to work without linking each and every checkbox to the cells?

I do not have enough knowlegde in excel to know which approach is best suited here.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You install the code like this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Use this new script:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 5/29/18 7:10 AM EDT
Cancel = True
Dim cc As Long
Dim Lastrow As Long
Dim r As Long
Dim c As Long
cc = ActiveSheet.ListObjects("Lageroversikt").ListColumns(2).Range.Column
If Target.Column = cc Then
Lastrow = ActiveSheet.ListObjects("Orderoversikt").Range.Rows.Count + 1
ActiveSheet.ListObjects("Orderoversikt").ListRows.Add AlwaysInsert:=True
r = Target.Row
c = Target.Column
Cells(r, c).Resize(, 15).Copy ActiveSheet.ListObjects("Orderoversikt").Range.Cells(Lastrow, 1)
End If
End Sub

 
Upvote 0
This script does not go into a module.
It runs when you double click on column (2) of your table
If you double click on row(2) column 2 of your row(2) will be copied to other table.
I'm assuming both tables are on the same sheet.
 
Upvote 0
Yes that worked! nice. Thanks for the help! so if i wanted to change it to column 1 of the list. i just change the "ListColumns(2).Range.Column" to ListColumns(1).Range.Column ?
 
Upvote 0
Did you double click on column 2 of your table?

So if your table starts in column A you need to double click on column B

Because you originally said you were going to put a checkbox in column A so I was not sure what column your table started on.

So I told the script to have you double click on column (2) of your table
 
Upvote 0
So is all this working now?

You should not use the first script I sent you.
It does not add to the table it just copies over the lastrow of the table

If all works then:

Now tell me again about wanting to delete rows from second table
 
Upvote 0
Yes, it works

Yeah i changed it to the second one.

yeah, it would be nice to be able to doubleclick to remove it from the list again.
Because currently i can't remove it, even when i delete it. some of the information comes back when i add a new row. The other problem is that the rows keeps increasing without starting from the top when i delete it. but that could be because of the first problem.
 
Upvote 0
Are you saying our first script works properly. And that subject is closed?

Now when you talk about wanting to delete

You said:
yeah, it would be nice to be able to doubleclick to remove it from the list

Remove what?
And are we talking about removing it from Table
Orderoversikt
 
Upvote 0
Or are you saying you want the row from Table(1) copied to Table(2)
And then want same row deleted from Table(1)
 
Upvote 0

Forum statistics

Threads
1,216,131
Messages
6,129,066
Members
449,485
Latest member
greggy

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