Help to get Cell value with multiple conditions

nhnn1986

Board Regular
Joined
Oct 12, 2017
Messages
92
Hi all

I need help to take value of Cell that:
with j = 2 to lastrow
if Cell(J;G).value = Cell(A2:A).value and Cell(i;B).value = "R101" then copy value in Cell(i;C) to Hj
if Cell(J;G).value = Cell(A2:A).value and Cell(i;B).value = "R102" then copy value in Cell(i;C) to Ij
if Cell(J;G).value = Cell(A2:A).value and Cell(i;B).value = "R103" then copy value in Cell(i;C) to Jj

This mean I want after run code, the result is:
H2 = 0, I2 = 0, J2 = 0
H3 = 5000, I3 = 6000, J3 = 7000
H4 = 10, I4 = 5, J4 = 20
..........

thanks./.

ABCDEFGHIJ
(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)
xxxxR101100zzz
xxxxR102200zzzz
xxxxR103500yyyy
yyyyR10110xxxx
yyyyR1025.....
yyyyR10320
zzzzR1015000
zzzzR1026000
zzzzR1037000
..............

<tbody>
</tbody>
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Cross posted http://www.vbaexpress.com/forum/sho...py-cell-value-with-two-conditions-by-VBA-code

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
Sorry i don't now This forum don't accept the question asked with another forum already
 
Upvote 0
We do not prohibit members from asking the same question elsewhere, we simply ask that you inform us by including a link to the other sites.

If your description on vbax is anything to go by, I'm not surprised that it's returning 0s as you have given a different description of what your data looks like.
Is the data you showed in post#1 accurate?
 
Upvote 0
We do not prohibit members from asking the same question elsewhere, we simply ask that you inform us by including a link to the other sites.

If your description on vbax is anything to go by, I'm not surprised that it's returning 0s as you have given a different description of what your data looks like.
Is the data you showed in post#1 accurate?
Yes, there's the same data.
I deleted column C,D before post in this forum because there's no meanning and value in column A too long so I rewrite to shorter as you see
 
Upvote 0
What about the R101 versus R-101?
 
Upvote 0
It may be "simpler" but if that is not what your data is like it wont work, we need accurate information in order to help.
try
Code:
Sub LookupData()
   Dim rng As Range
   
   Set rng = Range("A2", Range("A" & Rows.Count).End(xlUp))
   With Range("H2", Range("G" & Rows.Count).End(xlUp).Offset(, 1))
      .Resize(, 3).ClearContents
      .FormulaR1C1 = "=SUMPRODUCT((" & rng.Address(, , xlR1C1) & "=rc[-1])*(" & rng.Offset(, 1).Address(, , xlR1C1) & "=""R-101"")," & rng.Offset(, 2).Address(, , xlR1C1) & ")"
      .Offset(, 1).FormulaR1C1 = "=SUMPRODUCT((" & rng.Address(, , xlR1C1) & "=rc[-2])*(" & rng.Offset(, 1).Address(, , xlR1C1) & "=""R-102"")," & rng.Offset(, 2).Address(, , xlR1C1) & ")"
      .Offset(, 2).FormulaR1C1 = "=SUMPRODUCT((" & rng.Address(, , xlR1C1) & "=rc[-3])*(" & rng.Offset(, 1).Address(, , xlR1C1) & "=""R-103"")," & rng.Offset(, 2).Address(, , xlR1C1) & ")"
      .Resize(, 3).Value = .Resize(, 3).Value
   End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,201
Messages
6,123,617
Members
449,109
Latest member
Sebas8956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top