If Row 1 = Row 2 then delete row 2, else msgbox

  • Hi there,


    I'm trying to input a check into my macro. Basically the logic I'm trying to follow is:


    If Row 1 = Row 2 then delete row 2,
    ElseIf Row 1 <> Row 2 then Display MsgBox "Row 1 and Row 2 are different. Do you wish to continue?"
    If user selects yes, resume
    If user selects no, end sub and display MsgBox "Macro ended. Please correct changes manually"


    Can anyone help me if this isn't too much trouble?


    Thanks,
    Binning

  • Re: If Row 1 = Row 2 then delete row 2, else msgbox


    I'm not too sure on the rules for bumping here but this post has found itself on page 2 so I'm afraid it'll be ignored

  • Re: If Row 1 = Row 2 then delete row 2, else msgbox


    HaHoBe is there an issue with posting the same question on a different forum? There are a number of moderators on each who could help me here.

  • Re: If Row 1 = Row 2 then delete row 2, else msgbox


    I've figured this out on my own anyway. Sorry for failing to read the forum rules. For anyone who is interested please see below:



    Function to see if ranges are equal


    Code
    Function rangesAreEqual(rng1 As Range, rng2 As Range, _
        ws1 As Worksheet) As Boolean
        If rng1.Columns.Count <> rng2.Columns.Count Then Exit Function
        If rng1.Rows.Count <> rng2.Rows.Count Then Exit Function
        rangesAreEqual = ws1.Evaluate("=AND(EXACT(" & ws1.Name & "!" & _
                rng1.Address & "," & ws1.Name & "!" & rng2.Address & "))")
    End Function

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!