Compare two blank cells

Closed
Demolisher - Aug 3, 2009 at 03:27 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Aug 4, 2009 at 06:46 AM
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 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Aug 3, 2009 at 05:54 AM
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.
0
Never Done it before How to loop this one above
0
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Aug 4, 2009 at 06:46 AM
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
0