ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help on editing a function using a macro (https://www.excelbanter.com/excel-programming/392847-help-editing-function-using-macro.html)

CSUS_CE_Student[_2_]

Help on editing a function using a macro
 
A1 45.00
A2 49.00
A3 31.00
A4 34.00
A5 59.00
A6 21.00
A7 =SUM(A1:A7)

What i need to do is change the equasion in A7 from "=SUM(A1:A7)" to
"=RoundUp(SUM(A1:A7),0)". When i try to do this with this code

Sub RoundUP()
Dim x As String
x = ActiveCell.Formula
x = "=roundup(" & x & ",0)"
ActiveCell.Formula = x
End Sub

I get x= "=RoundUp(=SUM(A1:A7),0)"
I need to remove the extra internal = sign or do this a different way. How
can i do this?

Thanks!


Trevor Shuttleworth

Help on editing a function using a macro
 
Try:

x = "=roundup(" & right(x, len(x)-1) & ",0)"

Regards

Trevor


"CSUS_CE_Student" wrote in message
...
A1 45.00
A2 49.00
A3 31.00
A4 34.00
A5 59.00
A6 21.00
A7 =SUM(A1:A7)

What i need to do is change the equasion in A7 from "=SUM(A1:A7)" to
"=RoundUp(SUM(A1:A7),0)". When i try to do this with this code

Sub RoundUP()
Dim x As String
x = ActiveCell.Formula
x = "=roundup(" & x & ",0)"
ActiveCell.Formula = x
End Sub

I get x= "=RoundUp(=SUM(A1:A7),0)"
I need to remove the extra internal = sign or do this a different way.
How
can i do this?

Thanks!




Rick Rothstein \(MVP - VB\)

Help on editing a function using a macro
 
x = "=roundup(" & right(x, len(x)-1) & ",0)"

You can replace this...

Right(x, Len(x) - 1)

with this...

Mid(x, 2)

Rick


All times are GMT +1. The time now is 09:56 AM.

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