View Full Version : VBA CODE for Subtract two cells
elsuji
09-16-2019, 11:43 AM
Hi,
I have data in the range of A30 to B187. I want to subtract B-A and update in C( Example: C30=B30-A30) . If A30 & B30 is blank the C30 also blank.
How to write code for this
salim ali
09-16-2019, 12:08 PM
Try this macro
Sub my_code()
With Range("C30:C187")
.Formula = _
"=IF(AND(A30="""",B30=""""),"""",B30-A30)"
.Value = .Value
End With
End Sub
elsuji
09-16-2019, 12:41 PM
Dear Salim Ali
Thanks for your reply. The code is working good.
elsuji
09-17-2019, 02:17 AM
Dear Salim,
I have data updating in range "H30 to H186". If any value is going more than 2 in C column cell color to be change in yellow.
For example H40 value is >= +or- 2 then C40 cell color to be change in yellow and popup message to be display that " C40 value is crossed 2"
How can i do this code
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.