Hi all
I'm trying to grab data from two sheets by first doing a match.
The match works, but how can I now reference ws2 so that I can pick up data if this match is true?
Any help much appreciated
Danny
Sub Test_click()
Dim CurrentWB As Workbook
Dim Barrister, Barrister2, Box1, Box6, Box4, Box7, ws1, ws2 As String
Dim rRange, rcell As Range
ws1 = "$Invoices"
ws2 = "$Summary"
Set CurrentWB = ActiveWorkbook
CurrentWB.Worksheets(ws1).Activate
Set rRange = CurrentWB.Worksheets(ws1).Range("A1", Range("A65536").End(xlUp))
On Error Resume Next
With CurrentWB.Worksheets(ws1)
For Each rcell In rRange
If rcell = "Barrister" Then GoTo Nrcell
'Grab data from ws1
Barrister = rcell.Offset(0, 0)
Box1 = Format(rcell.Offset(0, 12), "#,##0.00")
Box6 = Format(rcell.Offset(0, 13), "#,##0.00")
'BarrMatch Check
Barrmatch = Application.Match(Barrister, CurrentWB.Worksheets(ws2).Range("A:A"), 0)
If IsError(Barrmatch) Then
'Do nothing
MsgBox "No match"
Else
'Match (Normal)
MsgBox "Barr: " & Barrister & " - Match" & vbNewLine & _
"Box1: " & Box1 & vbNewLine & _
"Box6: " & Box6
'Grab data from ws2
'With ws2???
'Barrister = rcell2.Offset(0, 0)
'Box4 = Format(rcell2.Offset(0, 11), "#,##0.00")
'Box7 = Format(rcell2.Offset(0, 12), "#,##0.00")
End If
Nrcell:
Next
End With
rRange = Nothing
End Sub
Bookmarks