Sub Md ()"'Macro1 Macro'macro recorded by BX, time: 2012-6-8'the number of columns in the macro can be entered A-iv or you can enter 1-256'Dim i%, j%, i1%, j1%, i2%, j2%myi= UCase (InputBox ("first column")) Myj= UCase (InputBox ("second column"))"'************************************If myi like"[A-z]"Theni= ASC (myi)- -ElseIf myi like"[A-i][a-z]"Theni= (ASC (left (myi,1)) - -) * -+ ASC (Right (myi,1)) - -ElseIf isnumeric (myi) Theni=Myielsei=1End ifif Myj like"[A-z]"Thenj= ASC (Myj)- -ElseIf Myj like"[A-i][a-z]"Thenj= (ASC (left (Myj,1)) - -) * -+ ASC (Right (Myj,1)) - -ElseIf isnumeric (myj) Thenj=Myjelsej=2End If'UCase to uppercase upper LCase turn lowercase lowerI2= + 'i-Column colorJ2 = + 'column J Color'change which two columns compare to the same background color'************************************'The following does not have to be modifiedApplication.ScreenUpdating =Falseif i= J Then J = i +1For I1=1To Cells (30000, i). End (3). Rowfor J1=1To Cells (30000, j). End (3). Rowif Cells (I1, i). Value=""Then Exit forif Cells (J1, J). Interior.ColorIndex<> +and Cells (I1, i). Value =Cells (J1, J). Value Thencells (I1, i). Interior.ColorIndex=I2cells (J1, J). Interior.ColorIndex=j2exit forend ifnextnextapplication.screenupdating=Truemsgbox "The comparison is complete! "& VbCrLf &"It's just a comparison."& I &"columns, and"& J &"columns of data"'If you don't want to pop up a hint, add the preceding'single quotes in English end Sub
VBA Excel compares two columns of data