Hi mates
Please How can I write the code for comparing two cells in different coloums in VBA.
like A1 has a value of 40 , B1 has a value of 50
I want a code to say
if the value of A1 grater than value of b1 do so and so.
Hi mates
Please How can I write the code for comparing two cells in different coloums in VBA.
like A1 has a value of 40 , B1 has a value of 50
I want a code to say
if the value of A1 grater than value of b1 do so and so.
Maybe something like this:
![]()
Please Login or Register to view this content.
If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.
---Keep on Coding in the Free World---
ok but how if I want all bs to be in the same format not only b1
like b2 ,b3 b4 I'll compare them with A1 a2 a 3 a4 and so on
Maybe if you could attach a mock workbook with a description of exactly what you want done we can be of more assistance. You could use a loop to loop the cells but a loop needs an ending point for which "and so on" does not provide.
i put this code
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value > Range("B1").Value Then
Target.EntireRow.Interior.ColorIndex = 7
End If
End Sub
the problem wherever i put a nu,ber in the sheet the entire row turned pink how to solve it
You have to use code tags when using VBA code in this forum. Please refer to rule #3 to see how to apply them. I cannot help you until you do.
Someone else may have to step in on this as I have to go to class in a couple of minutes.
![]()
Please Login or Register to view this content.
Compares cells in column B to cells in column A, starting at A2, in the same row.![]()
Please Login or Register to view this content.
It will mark the cells in column B if that cell has a different value than the value of the cell in column A
Regards
John
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks