![]() |
Create a vbCheckbox from code in vb command button
This one may be for the pro's only.
I have a program button that will return values from another spreadsheet and return them to a range on another sheet. I need my command button to also create a vb checkbox or on off radio button beside each entry that it copies. Each time the button is pressed the number of returns will be different. Users need to be able to select certain returned values and omit others and then process another button that will take the info from beside the selected checkboxes and copy it to another location. |
Create a vbCheckbox from code in vb command button
Thanks, Getting started now,
"Chip Pearson" wrote: The following code should get you started. It creates 11 checkboxes in cells B10:B20. Sub AAA() Dim N As Long Dim CHK As Excel.CheckBox Dim WS As Worksheet Dim R As Range Set WS = ThisWorkbook.Worksheets("Sheet1") For N = 10 To 20 Set R = WS.Cells(N, "B") Set CHK = WS.CheckBoxes.Add(Left:=R.Left, _ Top:=R.Top, _ Width:=R.Width, _ Height:=R.Height) With CHK .OnAction = "'" & ThisWorkbook.Name & "'!CheckBoxAction" End With Next N End Sub -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) "KJ MAN" wrote in message ... This one may be for the pro's only. I have a program button that will return values from another spreadsheet and return them to a range on another sheet. I need my command button to also create a vb checkbox or on off radio button beside each entry that it copies. Each time the button is pressed the number of returns will be different. Users need to be able to select certain returned values and omit others and then process another button that will take the info from beside the selected checkboxes and copy it to another location. |
Create a vbCheckbox from code in vb command button
After these checkboxes are created, you still must manually program them
correct? If so, Is there any way that they can be scripted from the code that creates them? I need them to be created after a search has been completed and when the user clicks the ckeckbox, the checkbox will retrieve information from the adjacent row. Thanks for eveything chip// "Chip Pearson" wrote: The following code should get you started. It creates 11 checkboxes in cells B10:B20. Sub AAA() Dim N As Long Dim CHK As Excel.CheckBox Dim WS As Worksheet Dim R As Range Set WS = ThisWorkbook.Worksheets("Sheet1") For N = 10 To 20 Set R = WS.Cells(N, "B") Set CHK = WS.CheckBoxes.Add(Left:=R.Left, _ Top:=R.Top, _ Width:=R.Width, _ Height:=R.Height) With CHK .OnAction = "'" & ThisWorkbook.Name & "'!CheckBoxAction" End With Next N End Sub -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) "KJ MAN" wrote in message ... This one may be for the pro's only. I have a program button that will return values from another spreadsheet and return them to a range on another sheet. I need my command button to also create a vb checkbox or on off radio button beside each entry that it copies. Each time the button is pressed the number of returns will be different. Users need to be able to select certain returned values and omit others and then process another button that will take the info from beside the selected checkboxes and copy it to another location. |
Create a vbCheckbox from code in vb command button
One more thing, I also need a code that will remove the checkboxes after
a process has been completed. "KJ MAN" wrote: After these checkboxes are created, you still must manually program them correct? If so, Is there any way that they can be scripted from the code that creates them? I need them to be created after a search has been completed and when the user clicks the ckeckbox, the checkbox will retrieve information from the adjacent row. Thanks for eveything chip// "Chip Pearson" wrote: The following code should get you started. It creates 11 checkboxes in cells B10:B20. Sub AAA() Dim N As Long Dim CHK As Excel.CheckBox Dim WS As Worksheet Dim R As Range Set WS = ThisWorkbook.Worksheets("Sheet1") For N = 10 To 20 Set R = WS.Cells(N, "B") Set CHK = WS.CheckBoxes.Add(Left:=R.Left, _ Top:=R.Top, _ Width:=R.Width, _ Height:=R.Height) With CHK .OnAction = "'" & ThisWorkbook.Name & "'!CheckBoxAction" End With Next N End Sub -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) "KJ MAN" wrote in message ... This one may be for the pro's only. I have a program button that will return values from another spreadsheet and return them to a range on another sheet. I need my command button to also create a vb checkbox or on off radio button beside each entry that it copies. Each time the button is pressed the number of returns will be different. Users need to be able to select certain returned values and omit others and then process another button that will take the info from beside the selected checkboxes and copy it to another location. |
All times are GMT +1. The time now is 06:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com