ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Case (https://www.excelbanter.com/excel-programming/407120-select-case.html)

jnf40

Select Case
 
Is there a way the following code can be written where the places where 8 and
10 would depend on a cell value? If the cell value = 424 then

dim myCase as string
myCase = range("A1").value

for i = 28 to myCase

Select Case i
case 28, 127, 226, 325, myCase

or if the cell value = 10 then

case 28, 127, 226, 325, 424, myCase

the increment of the case is 99

End Select

Next


OssieMac

Select Case
 
'where 8 and 10 would depend on a cell value' Don't really understand what
you mean here. However, if steps are always 99 then why not use something
like this:-

For i = 28 To myCase Step 99

'your code in here including test for cell value

Next


--
Regards,

OssieMac


"jnf40" wrote:

Is there a way the following code can be written where the places where 8 and
10 would depend on a cell value? If the cell value = 424 then

dim myCase as string
myCase = range("A1").value

for i = 28 to myCase

Select Case i
case 28, 127, 226, 325, myCase

or if the cell value = 10 then

case 28, 127, 226, 325, 424, myCase

the increment of the case is 99

End Select

Next



All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com