Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box and range selection
I have a list of several hundred items that users can choose. After all
items have been selected, would like to be able to copy those selected items to a second worksheet for sorting. All of my checkboxes will be in column A, and the associated item data will be in the same row as the individual check box (about three or four columns worth). Rather than build and code hundreds of check boxes with individual code, can I create a procedure that will copy only the appropriate ranges when the user clicks a button (selection complete)? Thanks in advance... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box and range selection
What kind of check boxes. From the control toolbox toolbar or from the
forms toolbar? You want the copy to happen as each checkbox is checked rather than process the sheet all at one time. What happens if the user checks the box, then changes their mind and unchecks it (the data has already been copied if it is copied on checking the box). -- Regards, Tom Ogilvy "Bob Wall" wrote in message ... I have a list of several hundred items that users can choose. After all items have been selected, would like to be able to copy those selected items to a second worksheet for sorting. All of my checkboxes will be in column A, and the associated item data will be in the same row as the individual check box (about three or four columns worth). Rather than build and code hundreds of check boxes with individual code, can I create a procedure that will copy only the appropriate ranges when the user clicks a button (selection complete)? Thanks in advance... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box and range selection
Bob,
Put a command button on the worksheet. Double click on it and it should take you to the sheet module for that worksheet. (if not, right click on the sheet tab and select view code. In the left dropdown at the top of the module, select commandbutton1 (use the actual name) and from the right dropdown select click). Private Sub Commandbutton1_Click() Dim obj As OLEObject Dim rng As Range Dim rng1 As Range For Each obj In Me.OLEObjects If TypeOf obj.Object Is MSForms.CheckBox Then Set rng = obj.TopLeftCell If rng.Column = 1 Then 'Column A, change to reflect location ' of the checkboxes If obj.Object.Value = True Then If rng1 Is Nothing Then Set rng1 = rng Else Set rng1 = Union(rng1, rng) End If End If End If End If Next If Not rng1 Is Nothing Then rng1.EntireRow.Copy _ Destination:=Worksheets("Sheet2").Range("A2") End If End Sub That worked for me. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... What kind of check boxes. From the control toolbox toolbar or from the forms toolbar? You want the copy to happen as each checkbox is checked rather than process the sheet all at one time. What happens if the user checks the box, then changes their mind and unchecks it (the data has already been copied if it is copied on checking the box). -- Regards, Tom Ogilvy "Bob Wall" wrote in message ... I have a list of several hundred items that users can choose. After all items have been selected, would like to be able to copy those selected items to a second worksheet for sorting. All of my checkboxes will be in column A, and the associated item data will be in the same row as the individual check box (about three or four columns worth). Rather than build and code hundreds of check boxes with individual code, can I create a procedure that will copy only the appropriate ranges when the user clicks a button (selection complete)? Thanks in advance... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can't check selection boxes | Excel Discussion (Misc queries) | |||
Narrow Range based on Selection in Another Range | Excel Discussion (Misc queries) | |||
Identifying a selection of a selection of a range | Excel Worksheet Functions | |||
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. | Excel Programming | |||
Check Selection | Excel Programming |