Compare two blank cells [Closed]

Report
-
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
-
Hello,

I'm trying to produce the spreadsheet that would compare any type of information that look identical.
For example you put two databases in two separate sheets and at third sheet it compares them and tell you weather it is true or false. The problem is I could not figure out how to compare the blank cells - So what I mean
if you have A1=1 at first sheet, A=1 at second so it is true, otherwise false, but if A1=Blank at first sheet and A1=Blank at second sheet, so leave it blank, if 1st is blank and second is value - false.

Please suggest, any ideas.

3 replies

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
796
ty this type of macro

Sub test()
If Worksheets("sheet1").Range("a1") = "" And Worksheets("sheet2").Range("a1") = "" Then
Worksheets("sheet3").Range("a1") = ""
ElseIf Worksheets("sheet1").Range("a1") = Worksheets("sheet2").Range("a1") Then
Worksheets("sheet3").Range("a1") = "true"
Else
Worksheets("sheet3").Range("a1") = "false"
End If

End Sub


if you want to compare many cells put it in a loop.
Never Done it before How to loop this one above
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
796
try this macro . study the code statements. You can see the logic and next time if you want to write a loop it will help you

If there is any bug post back

Sub TEST1()
Dim rng As Range, c As Range, rng2 As Range, rng3 As Range
Dim j As Integer, k As Integer
Worksheets("sheet3").Cells.Clear
Worksheets("sheet1").Activate
Set rng = Range(Range("A1"), Cells(Rows.Count, "a").End(xlUp))
For Each c In rng
j = c.Row
k = c.Column
Set rng2 = Worksheets("sheet2").Cells(j, k)
Set rng3 = Worksheets("sheet3").Cells(j, k)
If c = "" And rng2 = "" Then
rng3 = ""
ElseIf c = rng2 Then
rng3 = "True"
Else
rng3 = "false"
End If
Next c


End Sub

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!