Compile a variable for setting and examination Excel 2010 VBA

Bluked

New Member
Joined
Aug 6, 2014
Messages
2
I'm sorry I couldn't get HTMLMAKER to work. I hope it is ok to post my code like this.

I'm using Excel 2010. This is a short and sweet version of my program. Is there a way to compile the variable in blue below without having to write code for each variable i.e. machine101, machine102, etc.?

machineNumb has to be a string, because I move it to a cell later on and Speak it with Application.Speech.Speak

Public machineNumb As String
Public machine101 As Boolean
Public machine102 As Boolean
Public machine103 As Boolean
Public thisVariable As Variant

Sub MySub

machineNumb = 100
Do
machineNumb = machineNumb +1
If thisVariable = 1 Then
machine(machineNumb) = true 'I want this to set value of machine102, machine103, etc
End If
Loop Until machineNumb = 103
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Code:
dim arMechs(100)
Dim i As Integer

for i = 1 to 100
   arMechs(i) = true
next 

arMechs(100) = false
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,003
Members
449,203
Latest member
Daymo66

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