G
Guillermo
I've recently started programming VBA, I didn't believe I needed it,
but I'm recording a macro to replace formulas and if I'm not in an
error I think I can not replace them but using the final value or the
entire formula. I want to explain it::
Of course replace didn't work, that was my first option.
If I use range.value I have to introduce last solution.
If I use range.formula and aI don't use just cell's references but VBA
parameters too, formula doesn't work
For ex.
Sub replace4()
'nofunciona alternar formula con parámetros
Dim truerange As Range
Dim str As String
Dim num As Double
Set truerange = Range("a11", Cells(1084, 107))
If IsArray(truerange) Then
ar = truerange
row1 = truerange.Row
column1 = truerange.Column
lastrow = row1 + UBound(ar, 1) - 1
lastcolumn = column1 + UBound(ar, 2) - 1
For irow = row1 To lastrow
For icol = column1 To lastcolumn
str = Cells(irow, icol).Formula
If Mid(str, 1, 1) = "<" Then
num = CDbl(Mid(str, 2, 1000))
formu = "=" & num & "/2"
Cells(irow, icol).Formula = formu
End If
Next icol
Next irow
End If
End Sub
With that macro I wanted to replace values lower than a number by the
half of that number. The macro doesn't work and I think it's because
divide can't operate with num.
Another thing I want to do is to repalce mean by fcamg (fcamg is a
UDF) but it doesn't work, either. I'm thinking about doing fcamg to
work with mean argument.
Some times I would like to explicit formula so I can deduce what
procedure I have used to obtain that value. My problem is solved for
"<" and I think may solve for "mean", but I won't know what values are
calculated and what way. Before now I always left formulas in cells,
but I can do the same if I use macros to do this?.
Please, anybody who can help me with this interesting issue, Im
attending for your answer,
but I'm recording a macro to replace formulas and if I'm not in an
error I think I can not replace them but using the final value or the
entire formula. I want to explain it::
Of course replace didn't work, that was my first option.
If I use range.value I have to introduce last solution.
If I use range.formula and aI don't use just cell's references but VBA
parameters too, formula doesn't work
For ex.
Sub replace4()
'nofunciona alternar formula con parámetros
Dim truerange As Range
Dim str As String
Dim num As Double
Set truerange = Range("a11", Cells(1084, 107))
If IsArray(truerange) Then
ar = truerange
row1 = truerange.Row
column1 = truerange.Column
lastrow = row1 + UBound(ar, 1) - 1
lastcolumn = column1 + UBound(ar, 2) - 1
For irow = row1 To lastrow
For icol = column1 To lastcolumn
str = Cells(irow, icol).Formula
If Mid(str, 1, 1) = "<" Then
num = CDbl(Mid(str, 2, 1000))
formu = "=" & num & "/2"
Cells(irow, icol).Formula = formu
End If
Next icol
Next irow
End If
End Sub
With that macro I wanted to replace values lower than a number by the
half of that number. The macro doesn't work and I think it's because
divide can't operate with num.
Another thing I want to do is to repalce mean by fcamg (fcamg is a
UDF) but it doesn't work, either. I'm thinking about doing fcamg to
work with mean argument.
Some times I would like to explicit formula so I can deduce what
procedure I have used to obtain that value. My problem is solved for
"<" and I think may solve for "mean", but I won't know what values are
calculated and what way. Before now I always left formulas in cells,
but I can do the same if I use macros to do this?.
Please, anybody who can help me with this interesting issue, Im
attending for your answer,