LocalNeko
New Member
- Joined
- Oct 22, 2019
- Messages
- 8
Hello Once Again.
I've been working on a project that I previously posted here. Looking at it from another angle, I think I found a solution where-in I need help.
Here is the code I am Using
Now that code would compare the two sheets but based only on column B. That's where I need help.
I need help so that the two sheets would compare based on the rows, not columns. Because I need the rows to be exactly matched for me not to copy/exactly different for me to copy.
I hope It's not as confusing as the first question.
Please Help.
Thank you.
I've been working on a project that I previously posted here. Looking at it from another angle, I think I found a solution where-in I need help.
Here is the code I am Using
Code:
Sub SheetCompare()
Sheets(6).Activate '6 is the main sheet
'Cells.Clear 'and clear all previous results
Dim LastRow As Integer
LastRow = Range("A" & Rows.Count).End(xlUp).Row
MsgBox LastRow
Range("A" & LastRow + 1).Select 'set cursor at the top
Sheets(17).Activate 'go to sheet 1 '17 is sheet 1
Range("a1").Select 'begin at the top
Dim search_for As String 'temp variable to hold what we need to look for
Dim cnt As Integer 'optional counter to find out how many rows we found
Do While ActiveCell.Value <> "" 'repeat the follwoing loop until it reaches a blank row
search_for = ActiveCell.Offset(0, 1).Value 'get a hold of the value in column B
Sheets(6).Activate 'go to sheet(6)
On Error Resume Next 'incase what we search for is not found, no errors will stop the macro
Range("b:b").Find(search_for).Select 'find the value in column B of sheet 6
If Err <> 0 Then 'If the value was not found, Err will not be zero
On Error GoTo 0 'clearing the error code
Sheets(17).Activate 'go back to sheet 1
r = ActiveCell.Row 'get a hold of current row index
Range(r & ":" & r).Select 'select the whole row
cnt = cnt + 1 'increment the counter
Selection.Copy 'copy current selection
Sheets(17).Activate 'go to sheet 17
Range("A" & LastRow + 1).Select
Selection.PasteSpecial xlPasteAll 'Past the entire row to sheet 17
ActiveCell.Offset(1, 0).Select 'go down one row to prepare for next row.
End If
Sheets(1).Activate 'return to sheet 1
ActiveCell.Offset(1, 0).Select 'go to the next row
Loop 'repeat
Sheets(6).Activate 'go to sheet 3 to examine findings
MsgBox "I have found " & cnt & " rows that did not exist in sheet 2"
End Sub
Now that code would compare the two sheets but based only on column B. That's where I need help.
I need help so that the two sheets would compare based on the rows, not columns. Because I need the rows to be exactly matched for me not to copy/exactly different for me to copy.
I hope It's not as confusing as the first question.
Please Help.
Thank you.