Tricky function for a VBA newbie -
here's problem. need compare 2 sets of cells on 2 different worksheet.
on sheet 1, cells a1 , a2. on sheet 2, cells a1 , a2.
on sheet 1, each cells populated single digit number, 1 being greater other, eg: 1-2, 2-1, 3-1, etc. , never equal another.
on sheet 2, 1 of cell populated single digit number. other cell empty.
i need determine if non empty cell on sheet 2 same cell cell on sheet 1 containing greater number.
unfortunatly have next 0 knowledge of vba, trying learn tutorial can't seem figure out how write one. me please?
thank much.
sub doit() dim sh1 worksheet, sh2 worksheet set sh1 = worksheets("first") set sh2 = worksheets("second") dim ivalue1 long if sh1.cells(2, 1) > sh1.cells(1, 1) ivalue1 = sh1.cells(2, 1) else ivalue1 = sh1.cells(1, 1) end if dim ivalue2 long if len(sh2.cells(2, 1)) = 0 ivalue2 = sh2.cells(1, 1) else ivalue2 = sh2.cells(2, 1) end if if ivalue1 = ivalue2 msgbox "equal" else msgbox "different" end if end sub
Comments
Post a Comment