List comparison

maxjohnson

New Member
Joined
Jul 20, 2006
Messages
45
I am trying to go through a long list making comparisons using a macro. say I have the following:

Col A Column B Column C
20 20 10
20 25 10
30 30 10
20 30 10

If the value in Col A = the Value in Col B, I want The value in Col C to be replaced by half the original value. In other words, the value in Col C for row 1 would be replaced by 5. There are thousands of rows. Can someone tell me a quick way to do this?

Thanks

Max
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
L

Legacy 63186

Guest
in Column D inserft the fomula =if(A1=B1,C1/2,C1) then use this formula for the rest of the data in the column.
 

maxjohnson

New Member
Joined
Jul 20, 2006
Messages
45
List Comparison

Thanks for the reply, but I am looking for something in VBA to place the results in column C. The following will work but I don't want to write it for every single row. Maybe it could be a loop or something. My program is already slow, so I am looking for something that will process fast.

If Worksheets("SHEET1").Range("A3") = Worksheets("SHEET1").Range _("B3") Then
Worksheets("SHEET1").Range("C3") = Worksheets("SHEET1").Range _("C3") / 2
End If

thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,133,656
Messages
5,660,148
Members
418,554
Latest member
Avalanchez

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top