Multiple cell values based on 2 columns with specific number

CsJHUN

Active Member
Joined
Jan 13, 2015
Messages
360
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
  2. Mobile
Hi Board,

Does anyone has advice about this problem.
I have this 2 sample table ("A1:D11" and "F1:G6")
[TABLE="class: head"]
<tbody>[TR="bgcolor: #888888"]
[TH][/TH]
[TH]
A
[/TH]
[TH]
B
[/TH]
[TH]
C
[/TH]
[TH]
D
[/TH]
[TH]
E
[/TH]
[TH]
F
[/TH]
[TH]
G
[/TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
1
[/TD]
[TD]
Grouping​
[/TD]
[TD]
Date​
[/TD]
[TD]
Data name​
[/TD]
[TD]
Data value​
[/TD]
[TD][/TD]
[TD]
Group​
[/TD]
[TD]
Multiplier​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
2
[/TD]
[TD]
1​
[/TD]
[TD]
1/1/2017​
[/TD]
[TD]
Need to multiply​
[/TD]
[TD]
6​
[/TD]
[TD][/TD]
[TD]
1​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
3
[/TD]
[TD]
1​
[/TD]
[TD]
1/1/2017​
[/TD]
[TD]
Not need to multiply​
[/TD]
[TD]
10​
[/TD]
[TD][/TD]
[TD]
2​
[/TD]
[TD]
6​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
4
[/TD]
[TD]
1​
[/TD]
[TD]
1/1/2017​
[/TD]
[TD]
Not need to multiply​
[/TD]
[TD]
4​
[/TD]
[TD][/TD]
[TD]
3​
[/TD]
[TD]
9​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
5
[/TD]
[TD]
2​
[/TD]
[TD]
1/1/2017​
[/TD]
[TD]
Not need to multiply​
[/TD]
[TD]
10​
[/TD]
[TD][/TD]
[TD]
4​
[/TD]
[TD]
2​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
6
[/TD]
[TD]
2​
[/TD]
[TD]
1/1/2017​
[/TD]
[TD]
Need to multiply​
[/TD]
[TD]
5​
[/TD]
[TD][/TD]
[TD]
5​
[/TD]
[TD]
6​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
7
[/TD]
[TD]
2​
[/TD]
[TD]
1/1/2017​
[/TD]
[TD]
Not need to multiply​
[/TD]
[TD]
4​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
8
[/TD]
[TD]
3​
[/TD]
[TD]
1/2/2017​
[/TD]
[TD]
Not need to multiply​
[/TD]
[TD]
5​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
9
[/TD]
[TD]
1​
[/TD]
[TD]
1/2/2017​
[/TD]
[TD]
Need to multiply​
[/TD]
[TD]
2​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
10
[/TD]
[TD]
2​
[/TD]
[TD]
1/2/2017​
[/TD]
[TD]
Not need to multiply​
[/TD]
[TD]
2​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
11
[/TD]
[TD]
5​
[/TD]
[TD]
1/2/2017​
[/TD]
[TD]
Not need to multiply​
[/TD]
[TD]
1​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I would like to multiple each group "need to multiply" values for each day with the group multiplier. (with macro if possible :) )
For example:
- D2 has to be 12 (6*2)
- D6 = 30 (5*6)
- D9 = 4 (2*2)

Thanks in advance!
John
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG23Feb15
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Rng2 [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]Set[/COLOR] Rng2 = Range(Range("G2"), Range("G" & Rows.Count).End(xlUp))
[COLOR="Navy"]With[/COLOR] Application
  [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        Dn.Offset(, 3).Value = Dn.Offset(, 3).Value * _
        .Index(Rng2, .Match(Dn.Value, Rng2.Offset(, -1), 0))
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this:
The value in column "C" must be exactly like this:
"Need to multiply"

Code:
Sub Grouping()
Application.ScreenUpdating = False
Dim i As Long
Dim ans As Long
Dim anss As Long
Dim Lastrow As Long
Dim aa As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 2 To Lastrow
        If Cells(i, "C").Value = "Need to multiply" Then
            ans = Cells(i, 1).Value
            aa = Cells(i, "D").Value
            anss = Range("F1").Offset(ans, 1).Value
            Cells(i, "D").Value = aa * anss
        End If
    Next

Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Thanks guys for replies both looks pretty promising. Didn't have time to check back soon enough. But managed to write (at and between meetings :) ) one macro which satisfy the leaders.
This is the result for the real (not example) sheets/tables

Code:
Sub vodor_szorzo()Dim vodor As Variant
lr = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row


For Each vodor In Range("D2:D" & lr)    ' get the full range of 'data name'
    If vodor.Value = "vödör száma" Then   'vödör száma = need to modify
    paszta = vodor.Offset(0, -3).Value   'get the group
    szorzo_ertek = Range("Q" & Range("N1:N20").Find(paszta).Offset(-1, 0).Row + 1)  'find the group mutiplier
    vodor.Offset(0, 1).Value = vodor.Offset(0, 1).Value * szorzo_ertek   'write back the multiplied value
    End If
Next vodor


End Sub

Thank you very much again!
 
Upvote 0
Sounds like your saying you wrote your own script and do not need any more help from us.
Thanks guys for replies both looks pretty promising. Didn't have time to check back soon enough. But managed to write (at and between meetings :) ) one macro which satisfy the leaders.
This is the result for the real (not example) sheets/tables

Code:
Sub vodor_szorzo()Dim vodor As Variant
lr = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row


For Each vodor In Range("D2:D" & lr)    ' get the full range of 'data name'
    If vodor.Value = "vödör száma" Then   'vödör száma = need to modify
    paszta = vodor.Offset(0, -3).Value   'get the group
    szorzo_ertek = Range("Q" & Range("N1:N20").Find(paszta).Offset(-1, 0).Row + 1)  'find the group mutiplier
    vodor.Offset(0, 1).Value = vodor.Offset(0, 1).Value * szorzo_ertek   'write back the multiplied value
    End If
Next vodor


End Sub

Thank you very much again!
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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