excel experts help

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

i have six columns in excel. A B C D E F. i need to compare A with D, B with E and C with F(row by row)..and see if all three match. is there any formula to highlight the rows(by giving it different color, or presenting in BOLD or any other mechanism) A matches with D, B matches with E and C matches with F? plz help if anyone has any idea on excel formulas....

jhyaikuti · May 19, 2009 11:11 AM · 17,263 views

7 Replies

I have been trying to learn it myself for sometime now.. There is no easy way. You need to use macro in excel... For using macro in Excel http://office.microsoft.com/en... Create new macro with following code and run Here is the code for you Sub bolding() Dim r As Integer For r = 1 To ActiveSheet.UsedRange.Rows.Count     If Cells(r, 1).Value = Cells(r, 4).Value Then         Range("A" & r).EntireRow.Font.ColorIndex = 10     ElseIf Cells(r, 2).Value = Cells(r, 5).Value Then         Range("A" & r).EntireRow.Font.Bold = True     ElseIf Cells(r, 3).Value = Cells(r, 6).Value Then         Range("A" & r).EntireRow.Font.ColorIndex = 3     End If Next r End Sub Error handling can be improved..... Enjoy

Prad · May 19, 2009 2:50 PM

Answer to your first question is =AND(A1=D1,B1=E1,C1=F1) Excel does the second part, probably Prad is correct, I don't know. Last edited: 19-May-09 03:18 PM

_ · May 19, 2009 3:15 PM

You can solve this problem entirely in EXCEL here is the formula =IF(EXACT(A1,B1),IF(EXACT(B1,C1),IF(EXACT(C1,D1),IF(EXACT(D1,E1),IF(EXACT(E1,F1),"TRUE","FALSE"),"FALSE"),"FALSE"),"FALSE"),"FALSE") This should work. However I use Excel 2007 so 2003 might be little different. But I think this should work in 2003 as well.

calciteko · May 19, 2009 7:03 PM

option explicit Sub sajha()  'vba for excel to 'determine if the adjacent cells have equal value     'declare variables     Dim myData As Range     Dim myRow As Range     Dim myCell As Range     Dim colCount As Long          Dim leftCell As Range     Dim rightCell As Range          'assign range     Set myData = Selection          'remove previous color     myData.Interior.ColorIndex = xlColorIndexNone          For Each myRow In myData.Rows     colCount = 0         For Each myCell In myRow.Cells             colCount = colCount + 1                          'test for odd numbered columns in selection             If (colCount / 2 - colCount \ 2 <> 0) Then                 Set leftCell = myCell                 Set rightCell = myCell.Offset(0, 1)                 If leftCell.Value = rightCell.Value Then                    leftCell.Interior.Color = vbGreen                    rightCell.Interior.Color = vbGreen                 End If                              End If         Next     Next End Sub

rajeshHamal · May 19, 2009 10:55 PM

'INSTRUCTION : 'Add the following in vba module window [Alt+F11] 'select a block of cells containing data 'then run the code 'matching data will be colored green Option explicit Sub sajha()     'declare variables     Dim myData As Range     Dim myRow As Range     Dim myCell As Range     Dim colCount As Long          Dim leftCell As Range     Dim rightCell As Range          'assign range     Set myData = Selection          'remove previous color     myData.Interior.ColorIndex = xlColorIndexNone          For Each myRow In myData.Rows     colCount = 0         For Each myCell In myRow.Cells             colCount = colCount + 1                          'test for odd numbered columns in selection             If (colCount / 2 - colCount \ 2 <> 0) Then                 Set leftCell = myCell                 Set rightCell = myCell.Offset(0, 1)                 If leftCell.Value = rightCell.Value Then                    leftCell.Interior.Color = vbGreen                    rightCell.Interior.Color = vbGreen                 End If                              End If         Next     Next End Sub

rajeshHamal · May 19, 2009 11:08 PM

'compares a to d, b to e.. like that 'but it is more generic 'you can select any range of data 'as long as columns count is even Option Explicit Option Base 1 Sub sajha2()     Dim c As Long     Dim r As Long     Dim leftCell As Range     Dim rightCell As Range     Dim leftRange As Range     Dim rightRange As Range     Dim myRange As Range     Set myRange = Selection        myRange.Interior.ColorIndex = xlColorIndexNone     Dim colCount As Long     Dim rowCount As Long     colCount = myRange.Columns.count     rowCount = myRange.Rows.count     Dim topLeft As Range     Dim botRight As Range          'create two data ranges     'left part     Set topLeft = myRange.Cells(1, 1)     Set botRight = myRange.Cells(rowCount, colCount / 2)     Set leftRange = Range(topLeft, botRight)          'right part     Set topLeft = myRange.Cells(1, colCount / 2 + 1)     Set botRight = myRange.Cells(rowCount, colCount)     Set rightRange = Range(topLeft, botRight)          'processing     For r = 1 To rowCount         For c = 1 To leftRange.Columns.count             Set leftCell = leftRange.Cells(r, c)             Set rightCell = rightRange.Cells(r, c)             If leftCell.Value = rightCell.Value Then                 leftCell.Interior.Color = vbGreen                 rightCell.Interior.Color = vbGreen                              End If         Next c     Next r End Sub

rajeshHamal · May 20, 2009 12:30 AM

Can you paste the problem?  

बैरागिकाइलो · May 21, 2009 5:03 PM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all