Reconciliation Macro

andrewbrown91

New Member
Joined
Dec 8, 2012
Messages
2
Hi,

I am having an issue with the below, the error I get is that the loop until function needs a do, but I can see that its there.

Please let me know what I am missing/other mistakes with this.

The idea is for all the rows in sheet 2, their value in column A to be compared to row B in sheet 1 and if there is a match, the row be pasted to the matching sheet.

Sub Matching()


Sheets("Sheet2").Select
Range("A1").Select

Do


Set Check = Application.Intersect(ActiveCell, Sheets("Sheet1"))

If Check Is Nothing Then

ActiveCell.Offset(1, 0).Select

Else

Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Matching").Select
Range("A1").Select

If IsEmpty(ActiveCell.Offset(1, 0)) Then
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else: Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Sheets("Sheet2").Select

ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell.Offset(0, 1))




End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You seem to be missing 2 End Ifs. The following code compiles but all that selecting should not be necessary.

Code:
Sub Matching()
Dim check As Range
Sheets("Sheet2").Select
Range("A1").Select
Do
    Set check = Application.Intersect(ActiveCell, Sheets("Sheet1"))
    If check Is Nothing Then
        ActiveCell.Offset(1, 0).Select
    Else
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.Copy
        Sheets("Matching").Select
        Range("A1").Select
        If IsEmpty(ActiveCell.Offset(1, 0)) Then
        ActiveCell.Offset(1, 0).Select
        ActiveSheet.Paste
        Else
            Selection.End(xlDown).Select
            ActiveCell.Offset(1, 0).Select
            ActiveSheet.Paste
            Sheets("Sheet2").Select
            ActiveCell.Offset(1, 0).Select
        End If
    End If
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
End Sub
 
Upvote 0
Thanks for your help. Still having issues with the intersect function. Getting a mismatch error...
Any tips on reducing the amount of selecting

Thanks,
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top