Aero
05-09-2010, 04:06 PM
I'm trying to find an expression for something like this :
http://i44.tinypic.com/2qalico.png
The left column are the thousands, then the hundreds, then the dozens,...
(i think you get the picture)
Now i could do this like so:
=A1*1000+B1*100+C1*10+D1*1
However there is a problem:
- the number has a variable length, it could be only '13', but could also be '15646847'
( in the beginning i will know the length of the number, for instance: 100-999 or 1000-9999 , ...)
( the equation signal is for illustration purposes only, it's actually like this: 0-2-4-0-240 )
Can someone push me in the right direction?
(i can do it using VBA / normal expressions in Excel)
EDIT: after some thinking it's actually not that hard to achieve:
(somewhat edited from my situation)
Dim index As Integer
Dim counter As Integer
Dim expression As String
counter = WorksheetFunction.Power(10, lengthNumber)
expression = "="
For index = 1 To lengthNumber
expression = expression & Cells(index, index).Address(False, False) & "*" & counter & "+"
counter = counter / 10
Next index
expression = expression & "0"
ws.Range(lengthNumber + 1).Value = expression
http://i44.tinypic.com/2qalico.png
The left column are the thousands, then the hundreds, then the dozens,...
(i think you get the picture)
Now i could do this like so:
=A1*1000+B1*100+C1*10+D1*1
However there is a problem:
- the number has a variable length, it could be only '13', but could also be '15646847'
( in the beginning i will know the length of the number, for instance: 100-999 or 1000-9999 , ...)
( the equation signal is for illustration purposes only, it's actually like this: 0-2-4-0-240 )
Can someone push me in the right direction?
(i can do it using VBA / normal expressions in Excel)
EDIT: after some thinking it's actually not that hard to achieve:
(somewhat edited from my situation)
Dim index As Integer
Dim counter As Integer
Dim expression As String
counter = WorksheetFunction.Power(10, lengthNumber)
expression = "="
For index = 1 To lengthNumber
expression = expression & Cells(index, index).Address(False, False) & "*" & counter & "+"
counter = counter / 10
Next index
expression = expression & "0"
ws.Range(lengthNumber + 1).Value = expression