two criteria to match

  • Thread starter Thread starter nk
  • Start date Start date
N

nk

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?
 
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
 
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...
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top