ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check Box Macro (https://www.excelbanter.com/excel-programming/286950-check-box-macro.html)

Jason Watts

Check Box Macro
 
Hello all,
I need a macro that will allow me to asign a check box to a specific row and when I check the box centain cells in that row will be sent to another sheet. I need to do this with multiple rows on multiple sheets with all info going to one sheet.

Tom Ogilvy

Check Box Macro
 
If you use a checkbox from the forms toolbar

Public Cbox_click()
Dim cBox as CheckBox
set cBox = Application.Caller
Dim rng as Range
set rng = Cells(cbox.TopLeftCell,1)
rng.Range("A1,D1,F1:H1").Copy Destination:= _
worksheets("Master").Cells(rows.count,1).End(xlup) (2)
End Sub

assign this to all you checkboxes. Place the checkbox on the row you want
it to refer to.

Regards,
Tom Ogilvy

"Jason Watts" wrote in message
...
Hello all,
I need a macro that will allow me to asign a check box to a specific row

and when I check the box centain cells in that row will be sent to another
sheet. I need to do this with multiple rows on multiple sheets with all
info going to one sheet.



Jason Watts

Check Box Macro
 
Tom
Every time I run the macro I get a Compile error: Invalid outside procedure at Set cBox = Application.Calle


Tom Ogilvy

Check Box Macro
 
Had a couple of typos in the procedu

Public Sub Cbox_click()
Dim cBox As CheckBox
Dim rng As Range
Set cBox = ActiveSheet.CheckBoxes(Application.Caller)
Set rng = Cells(cBox.TopLeftCell.Row, 1)
rng.Range("A1,D1,F1:H1").Copy Destination:= _
Worksheets("Master").Cells(Rows.Count, 1).End(xlUp)(2)
End Sub

Might want to add:

Public Sub Cbox_click()
Dim cBox As CheckBox
Set cBox = ActiveSheet.CheckBoxes(Application.Caller)
if cbox.Value = xlOn then
Dim rng As Range
Set rng = Cells(cBox.TopLeftCell.Row, 1)
rng.Range("A1,D1,F1:H1").Copy Destination:= _
Worksheets("Master").Cells(Rows.Count, 1).End(xlUp)(2)
End if
End Sub

Also format the checkbox so, under protection, the choice is "don't move or
size with cells" if your checkbox overlaps a cell you are copying (or it
might get copied).




--
Regards,
Tom Ogilvy

Jason Watts wrote in message
...
Tom,
Every time I run the macro I get a Compile error: Invalid outside

procedure at Set cBox = Application.Caller





All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com