Make font Change to all also future Listbox

Darkforce

New Member
Joined
Mar 4, 2020
Messages
20
Office Version
  1. 365
Platform
  1. Windows
I have this code that change font size form an cell in excel to all ListBox I have
Dim FontSize As Integer

FontSize = Worksheets(7).Range("B1")
Set xLstBox = ActiveSheet.AddOptInletTable
Set xLstBox2 = ActiveSheet.AddOptInletTableCombi
Set xLstBox3 = ActiveSheet.AddOptLHF6114
Set xLstBox4 = ActiveSheet.AddOptKL30Special
Set xLstBox5 = ActiveSheet.AddOptLKS6114

xLstBox.Font.Size = FontSize
xLstBox2.Font.Size = FontSize
xLstBox3.Font.Size = FontSize
xLstBox4.Font.Size = FontSize
xLstBox5.Font.Size = FontSize


What I want is an code that make this Change to all Listbox without having to update the code ..Even if I add more listbox later.. is there not a way to run this maybe by index and simple make a count and run through all of the Listbox ?


something like this


Dim FontSize As Integer

FontSize = Worksheets(7).Range("B1")

For i=1 to Listbox.count-1 then
ListBox(i).Font.Size =FontSize

next i


I am very new at this so hope you can help
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
is the a way to get this one to work ?

For i = 1 To 5
Set xLstBox = ActiveSheet.Shapes.Range(Array(i))
xLstBox.Font.Size = FontSize
Next i
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,773
Members
449,336
Latest member
p17tootie

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