Loop and add to selection

pingme89

Board Regular
Joined
Jan 23, 2014
Messages
176
Office Version
  1. 365
Platform
  1. Windows
I have hundreds of buttons on a worksheet.
The buttons are labelled for example B12down, B12up, B13down, B13up.... etc.

I only want to select buttons with "down" in the button name. I made some code already, but after selecting one button, upon going to the next button and selecting, the previous selection becomes unselected. Is there a way I can add to the already selected buttons?

Dim wbname As String
Dim button As OLEObject
Dim t As Range


wbname = ThisWorkbook.Name
Workbooks(wbname).Worksheets("Walkthrough").Activate


For i = 9 To 10
For j = 3 To 5
ColumnLetter = Split(Cells(1, j).Address, "$")(1)
Set t = ActiveSheet.Range(ColumnLetter & i)
rng = rng & "," & ColumnLetter & i & "down"
Next j
Next i
L = Len(rng)
rng = Right(rng, L - 1)
Workbooks(wbname).Worksheets("Walkthrough").Shapes(rng).Select
 

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.
Originally I had the select portion in the loop. It didn't work so I took it out of the loop. However, this still doesn't work.
 
Upvote 0
What do you want to do with the selected buttons?
 
Upvote 0
You need to create an array of the button names then use Shapes.Range(array).Select.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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