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")
A
B
C
D
E
F
G
1
Grouping​
Date​
Data name​
Data value​
Group​
Multiplier​
2
1​
1/1/2017​
Need to multiply​
6​
1​
2​
3
1​
1/1/2017​
Not need to multiply​
10​
2​
6​
4
1​
1/1/2017​
Not need to multiply​
4​
3​
9​
5
2​
1/1/2017​
Not need to multiply​
10​
4​
2​
6
2​
1/1/2017​
Need to multiply​
5​
5​
6​
7
2​
1/1/2017​
Not need to multiply​
4​
8
3​
1/2/2017​
Not need to multiply​
5​
9
1​
1/2/2017​
Need to multiply​
2​
10
2​
1/2/2017​
Not need to multiply​
2​
11
5​
1/2/2017​
Not need to multiply​
1​

<tbody>
</tbody>

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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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,215,692
Messages
6,126,235
Members
449,303
Latest member
grantrob

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