Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change a Variable Name in a For...Loop
Is it possible to change the name of a variable in a For...Loop? I am trying
to avoid using a bunch of If...Then Statements. Below is my attempt at the for loop and the If...Then Statement I am trying to avoid. 'PAINT MATERIAL COSTS Dim i as Byte Dim TotalPaint As Currency Dim Paint1 As Currency Dim Paint2 As Currency Dim Paint3 As Currency Dim Paint4 As Currency Dim Paint5 As Currency Dim Paint6 As Currency For i = 1 To Val(tbxColorsP) '1 < tbxColorsP < 6 If mpgPaint.Pages(i-1).Visible = True Then Object.Name("Paint" & i) = FaceSqFt * Val("cboAreaP" & i) / 100 * Val("tbxColorsP" & i) * PlasticPaint_C Else Exit For End If Next i TotalPaint = Paint1 + Paint2 + Paint3 + Paint4 + Paint5 + Paint6 ******************** If mpgPaint.Pages(0).Visible = True Then Paint1 = FaceSqFt * Val(cboAreaP1) / 100 * Val(tbxColorsP1) * PlasticPaint_C End If If mpgPaint.Pages(1).Visible = True Then Paint2 = FaceSqFt * Val(cboAreaP2) / 100 * Val(tbxColorsP2) * PlasticPaint_C End If If mpgPaint.Pages(2).Visible = True Then Paint3 = FaceSqFt * Val(cboAreaP3) / 100 * Val(tbxColorsP3) * PlasticPaint_C End If If mpgPaint.Pages(3).Visible = True Then Paint4 = FaceSqFt * Val(cboAreaP4) / 100 * Val(tbxColorsP4) * PlasticPaint_C End If If mpgPaint.Pages(4).Visible = True Then Paint5 = FaceSqFt * Val(cboAreaP5) / 100 * Val(tbxColorsP5) * PlasticPaint_C End If If mpgPaint.Pages(5).Visible = True Then Paint6 = FaceSqFt * Val(cboAreaP6) / 100 * Val(tbxColorsP6) * PlasticPaint_C End If TotalPaint = Paint1 + Paint2 + Paint3 + Paint4 + Paint5 + Paint6 Thanks in Advance Ryan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Loop with variable name? | Excel Discussion (Misc queries) | |||
LAST value of loop to be a variable | Excel Programming | |||
loop for-next with variable end | Excel Programming | |||
For Each ... Next loop - need to reference the loop variable | Excel Programming | |||
Loop with variable | Excel Programming |