The displayed sample data could be considered to be in A1:E4, with row and column titles (headers) in row 1 and column A, and so on. In that case, the formula for cell E4 (last row in the example) would be:
=IFERROR(VALUE(B4)*0.3,
VALUE(LEFT(B4,FIND("-",B4)-1))*0.3&"-"&VALUE(RIGHT(B4,LEN(B4)-FIND("-",B4)))*0.3)
First calculation in the IFERROR()
uses VALUE()
to indicate whether a single value exists in the target cell, or not. In the case of failure, the second calculation breaks apart the string forming the range into the piece to the left of the "-" and the piece to the right of it. It uses VALUE()
, this time to convert each string into a number and then multiplies each such by the ".3" and finally forms a string of the resulting left valuefactor, a new "-", and the resulting right valuefactor.
It does depend upon the consistent use of the "-" for separating the two components in "range" cells, though one could, with lots of effort, handle several possibilities. An alternate entry form might have "space-dash-space" or similar mess-ups but these would be better handled by inserting a TRIM()
function around the string pieces inside the VALUE()
wrappers to take off the leading or trailing spaces. Other variations might be found and one could probably find various clevernesses to deal with them.
It is very straightforward though, separating, operating upon, and remaking the strings. So your only real trouble will be dealing with the errant data entries people make (and there will be plenty). Not a problem though, if the data comes from some data source that is written by a program, not data entry!