View Full Version : Problem with Changing formula
ykcolsgo
03-23-2011, 02:36 AM
Hello
I want to change a cell formula when a button pressed and The formula must have an if statement!
I have tried this code but an 1004 error occurs.:banghead:
Private Sub CommandButton1_Click()
t = "=IF(5>=2;1;7)"
Cells(1, 1) = t
End Sub
thanks
Bob Phillips
03-23-2011, 02:54 AM
Private Sub CommandButton1_Click()
Cells(1, 1).Formula = "=IF(5>=2,1,7)"
End Sub
ykcolsgo
03-23-2011, 03:03 AM
Private Sub CommandButton1_Click()
Cells(1, 1).Formula = "=IF(5>=2,1,7)"
End Sub
Thank you very much:clap: It worked.
But I have still Problem!
can you test my sheet?(I have attached)
Thanks
Bob Phillips
03-24-2011, 12:11 PM
And the problem is ...?
ykcolsgo
03-24-2011, 12:19 PM
And the problem is ...?
The Problem is that 1004 error occurs!:(
Bob Phillips
03-24-2011, 02:50 PM
I give you a solution, you say it worked, and then you say you still have a problem, even though it is with another piece of code which you didn't present before and ignored the solution I previously gave. Sheesh!
Private Sub CommandButton1_Click()
Dim i As Integer
i = 12
t = "=IF(SUM(F8:F" + Trim(Str(i)) + ")>=K5,K5-I5,IF(SUM(F8:F" + Trim(Str(i)) + ")>=I5,SUM(F8:F" + Trim(Str(i)) + ")-I5,0))"
Cells(1, 1).Formula = t
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.