ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inputing variables (https://www.excelbanter.com/excel-programming/309334-inputing-variables.html)

Ben H

Inputing variables
 
Hi all. I have an input which will have 1 or 3 variables in it, all
seperated by a ",". It would look like this "2000" or "2000, 500, 3000" The
values are the conditions for a loop: the start, step and ending value. I
was trying to read it in using this code.
Holding = Split(I_Wt_Value, ",")
Weight(0) = Holding(0)
Weight(1) = Holding(1)
Weight(2) = Holding(2)
If IsEmpty(Weight(1)) Then
Weight(3) = 0
Weight(2) = Weight(0)
Weight(1) = Weight(0)
Else
Weight(3) = Weight(0) - Weight(1)
End If

The idea was to take the holding value and put it into an array since I
could use it a little easier but if there is one value instead of 3 in the
field, it spits out a "subscript out of range" error. I need to be able to
use it for both of those inputs I have earlier. Any ideas?

Thanks!

Tom Ogilvy

Inputing variables
 
if(instr(I_Wt_Value,",") = 0 then
I_Wt_Value = I_Wt_Value & ",0,0"
End if
Holding = Split(I_Wt_Value, ",")
Weight(0) = Holding(0)
Weight(1) = Holding(1)
Weight(2) = Holding(2)
If IsEmpty(Weight(1)) Then
Weight(3) = 0
Weight(2) = Weight(0)
Weight(1) = Weight(0)
Else
Weight(3) = Weight(0) - Weight(1)
End If

Or concatenate whatever is appropriate.
--
Regards,
Tom Ogilvy


"Ben H" wrote in message
...
Hi all. I have an input which will have 1 or 3 variables in it, all
seperated by a ",". It would look like this "2000" or "2000, 500, 3000"

The
values are the conditions for a loop: the start, step and ending value. I
was trying to read it in using this code.
Holding = Split(I_Wt_Value, ",")
Weight(0) = Holding(0)
Weight(1) = Holding(1)
Weight(2) = Holding(2)
If IsEmpty(Weight(1)) Then
Weight(3) = 0
Weight(2) = Weight(0)
Weight(1) = Weight(0)
Else
Weight(3) = Weight(0) - Weight(1)
End If

The idea was to take the holding value and put it into an array since I
could use it a little easier but if there is one value instead of 3 in the
field, it spits out a "subscript out of range" error. I need to be able

to
use it for both of those inputs I have earlier. Any ideas?

Thanks!





All times are GMT +1. The time now is 05:20 PM.

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