View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default two criteria to match

The "THEN" was missing ffrom the IF statemnt. I also added the line
continuation character ("_") to the long lines and put in the "end with".
this is only partial code, I'm assuming you have written the rest of the
macro.

RowCount = 3
With Sheets("Sheet A")
If (.Range("E" & RowCount) = Sheets("Sheet B").Range("S" & RowCount)) And _
(.Range("C" & RowCount) = Sheets("Sheet B").Range("D" & RowCount)) Then

.Range("G" & RowCount).Value = _
Sheets("Sheet B").Range("A" & RowCount).Value
.Range("H" & RowCount).Value = _
Sheets("Sheet B").Range("B" & RowCount).Value
.Range("I" & RowCount).Value = _
Sheets("Sheet B").Range("F" & RowCount).Value
.Range("J" & RowCount).Value = _
Sheets("Sheet B").Range("H" & RowCount).Value
End With


"nk" wrote:

Thank you, Joel... but I can't make it work receiving an error message
"compile error: expected: expression". I tried to find addition "then" "end
with" etc, but could not figure out what is the problem...

"Joel" wrote:

RowCount = 3
with sheets("Sheet A")
if (.Range("E" & RowCount) = sheets("Sheet B").Range("S" & RowCount)) and _
(.Range("C" & RowCount) = sheets("Sheet B").Range("D" & RowCount))

.Range("G" & RowCount).value = sheets("Sheet B").Range("A" &
RowCount).value
.Range("H" & RowCount).value = sheets("Sheet B").Range("B" &
RowCount).value
.Range("I" & RowCount).value = sheets("Sheet B").Range("F" &
RowCount).value
.Range("J" & RowCount).value = sheets("Sheet B").Range("H" &
RowCount).value



"nk" wrote:

Hello, appreciate your help...

- I am trying to populate Cell A, B, F and H in Sheet B into cells in Sheet
A starting from G3 in Sheet A.
- There is data already populated from Cell A3 to Cell F in Sheet A.
- If content in Cell S in Sheet B and content in Cell E in Sheet A as well
as content in Cell D in Sheet B and content in Cell C in Sheet A matche,
contents in Cell A, B, F and H in Sheet B need to be populated starting from
Cell G3 in Sheet A.

How can I do this?