Help required in amending a macro if poss

ghrek

Active Member
Joined
Jul 29, 2005
Messages
426
Hi

I have this macro that filters out data by using criterial

The macro at the moment goes into sheets 1 & 2 and filters out. What im trying to do is to compare the data between the 2 sheets and if data dont match I need whats missing from sheet 2 highlighted on sheet 1.

I also need to set it up so it goes all the way through the workbook selecting each unique criterial number but before it moves onto next number to filter I need it to pause and i have to push a key for it to continue and move onto next. Any ideas?

Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    Cells.Select
    Application.CutCopyMode = False
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Add2 Key:=Range( _
        "D1:D1039310"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet2").Sort
        .SetRange Range("A1:D1039310")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Sheets("Sheet1").Select
    Cells.Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add2 Key:=Range( _
        "D1:D1039310"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("A1:D1039310")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Rows("1:1").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Sheets("Sheet2").Select
    Rows("1:1").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Columns("A:A").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$A$1039312").AutoFilter Field:=1, Criteria1:="1382"
    Sheets("Sheet1").Select
    Columns("A:A").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$A$1039312").AutoFilter Field:=1, Criteria1:="1382"
    Columns("D:D").Select
    Sheets("Sheet2").Select
    Columns("D:D").Select

HIGHLIGHT DIFFERENCES BETWEEN SHEETS 1 & 2 ON SHEET 1 AND THEN I PUSH A KEY AND RUN AGAIN 

 ActiveSheet.Range("$A$1:$A$1039312").AutoFilter Field:=1, Criteria1:="1385"
    Sheets("Sheet1").Select
    Columns("A:A").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$A$1039312").AutoFilter Field:=1, Criteria1:="1385"
    Columns("D:D").Select
    Sheets("Sheet2").Select
    Columns("D:D").Select

Then again highlight and repeat etc all the way down. When complete I will have sheet 1 will all the normal and highlighted missing data.
End Sub
 
Last edited by a moderator:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Cross posted https://www.excelforum.com/excel-programming-vba-macros/1284006-need-help-with-amending-a-macro.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Cross posted https://www.excelforum.com/excel-programming-vba-macros/1284006-need-help-with-amending-a-macro.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.


deleted from that website and will concentrate on here.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,764
Members
448,991
Latest member
Hanakoro

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