financialdoc
New Member
- Joined
- Jan 27, 2005
- Messages
- 10
I need help with this macro. I'm new to the VBA thing and any help is greatly appreciated.
I have two sheets that need to be synchronized. The ranges have different amounts of cells, and so I'm not sure if I need to set up an array or not. Basically if the values column "A" and "B" in sheet 1 match up with column "A" and "B" in sheet two then I want the value in Column "C" of sheet 2 to be "TRUE" (for that row)
Here is what I have so far (and my Do statement is wrong already):
Sub Synchronize()
Dim arng As Range
Dim arng2 As Range
Dim arng3 As Range
Dim brng As Range
Dim brng2 As Range
Dim brng3 As Range
Set arng = Range("Sheet1!C2")
Set arng2 = Range("Sheet1!D2")
Set arng3 = Range("Sheet1!F2")
Set brng = Range("Sheet2!b2")
Set brng2 = Range("Sheet2!c2")
Set brng3 = Range("Sheet2!ax2")
arang3.Activate
Do
If arng3 = "Open" Then
If arng = brng And arng2 = brng2 Then
brng3.Value = "True"
End If
If arng3 = "Closed" Then
If arng = brng And arng2 = brng2 Then
brng3.Value = "True"
End If
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell)
End Sub
I have two sheets that need to be synchronized. The ranges have different amounts of cells, and so I'm not sure if I need to set up an array or not. Basically if the values column "A" and "B" in sheet 1 match up with column "A" and "B" in sheet two then I want the value in Column "C" of sheet 2 to be "TRUE" (for that row)
Here is what I have so far (and my Do statement is wrong already):
Sub Synchronize()
Dim arng As Range
Dim arng2 As Range
Dim arng3 As Range
Dim brng As Range
Dim brng2 As Range
Dim brng3 As Range
Set arng = Range("Sheet1!C2")
Set arng2 = Range("Sheet1!D2")
Set arng3 = Range("Sheet1!F2")
Set brng = Range("Sheet2!b2")
Set brng2 = Range("Sheet2!c2")
Set brng3 = Range("Sheet2!ax2")
arang3.Activate
Do
If arng3 = "Open" Then
If arng = brng And arng2 = brng2 Then
brng3.Value = "True"
End If
If arng3 = "Closed" Then
If arng = brng And arng2 = brng2 Then
brng3.Value = "True"
End If
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell)
End Sub