ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do i comapre 2 columns (https://www.excelbanter.com/excel-programming/308943-re-how-do-i-comapre-2-columns.html)

Tom Ogilvy

How do i comapre 2 columns
 
a formula can't do that unless the values in column B a produced by a
formula

=if(A1="C",-25,Current formula for B)

or in column C you could put in C1
=if(A1="C",-25,B1)
then drag fill this down your column. Then select the cells in C, do
Edit=Copy, then select B1 and do Edit=Pastespecial and select Values.

for code

Sub ReplaceValuesInB()
range(B1").Select
do
if activeCell.offset(0,-1).Value = "C" then
activeCell.Value = -25
End if
activeCell.offset(1,0).Select
loop while not isempty(activeCell)
End Sub

test any of these on a copy of your data.


--
Regards,
Tom Ogilvy


"Leo" wrote in message
...
HI Prods
I have situation here.
I have a column A and B
A B
D 25
C 23
D 45
C 56
D 34

Ineed to write a formula to compare these columns for the condition
if the cloumn A has the value C the the corresponding value in column B
should become -25.
How do i do this please let me know about it.
Thanks
Diwakar






All times are GMT +1. The time now is 06:04 AM.

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