View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_93_] Leith Ross[_93_] is offline
external usenet poster
 
Posts: 1
Default compare cell and insert vaalue in column Q


Hello Sal21,

This code should put "New" into the Master cell if there is n
correspondce with the User cell or the Master cell has a number, but n
description.


Code
-------------------
Public Sub UpdateInvoices()

Dim LastUserRow As Long
Dim WksMaster As Excel.Worksheet
Dim WksUser As Excel.Worksheet


Set WksMaster = Excel.Workbooks("Master.xls").Worksheets("Master")
Set WksUser = Excel.Workbooks("User.xls").Worksheets("User")

LastMasterRow = WksMaster.Cells(Rows.Count, "R").End(xlUp).Row
LastUserRow = WksUser.Cells(Rows.Count, "R").End(xlUp).Row

For J = 2 To LastUserRow
For I = 2 To LastMasterRow
If WksMaster.Cells(I, "R") = WksUser.Cells(J, "R") Then
WksMaster.Cells(I, "Q") = WksUser.Cells(I, "Q")
Else
WksMaster.Cells(I, "Q") = "New"
End If
If WksMaster.Cells(I, "Q") = "" Then WksMaster.Cells(I, "Q") = "New"
Next I
Next J

End Su
-------------------


By the way, if you have trouble writing something in English, feel fre
to write it in Italian. I am part Italian and can read it pretty well.

Ciao,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=47832