In my script I have:
My script is looking at cel F1 and if it contains the text "aaa_", it divides 160 (MyStores) by 8 and rounds it up to the nearest whole number.
But if it contains bbb_ also divide by 8
if ccc_ then divide by 6
if ddd_ the divide by 4
if eee_ then divide by 4 also
I have about 60 or so text strings I'm seaching for and about a dozen different numbers to divide by, but Is there a better way to do this?
I'm thinking there should be a better way than 60 "if" statements.
Is there a way to maybe to have a list of values the its' looking for as a variable, then based on text it found, divide by the corresponding value?
I'm thinking I would need to do doething like this:
But I'm not sure how to setup variables MyString or MyQty - any ideas?
Code:
MyStores = 160
Range("F1").Select
If InStr(1, (Range("F1").Value), "aaa_") Then
MySets = Application.RoundUp(MyStores / 8, 0)
End If
Range("F1").Select
If InStr(1, (Range("F1").Value), "bbb_") Then
MySets = Application.RoundUp(MyStores / 8, 0)
End If
Range("F1").Select
If InStr(1, (Range("F1").Value), "ccc_") Then
MySets = Application.RoundUp(MyStores / 6, 0)
End If
Range("F1").Select
If InStr(1, (Range("F1").Value), "ddd_") Then
MySets = Application.RoundUp(MyStores / 4, 0)
End If
Range("F1").Select
If InStr(1, (Range("F1").Value), "eee_") Then
MySets = Application.RoundUp(MyStores / 4, 0)
End If
My script is looking at cel F1 and if it contains the text "aaa_", it divides 160 (MyStores) by 8 and rounds it up to the nearest whole number.
But if it contains bbb_ also divide by 8
if ccc_ then divide by 6
if ddd_ the divide by 4
if eee_ then divide by 4 also
I have about 60 or so text strings I'm seaching for and about a dozen different numbers to divide by, but Is there a better way to do this?
I'm thinking there should be a better way than 60 "if" statements.
Is there a way to maybe to have a list of values the its' looking for as a variable, then based on text it found, divide by the corresponding value?
I'm thinking I would need to do doething like this:
Code:
Range("F1").Select
If InStr(1, (Range("F1").Value), MyString) Then
MySets = Application.RoundUp(MyStores / MyQty, 0)
End If
But I'm not sure how to setup variables MyString or MyQty - any ideas?