Formula Macro

smartguy

Well-known Member
Joined
Jul 14, 2009
Messages
778
Hello all,

Good day.

I Have excel file in the below format.


Excel 2013/2016
ABCDEFG
1ValueQTYABACADEFFinal Vlaue
2AB112341
3AB222214
4AC3456115
5AB412314
6AC5134415
Sheet1
Cell Formulas
RangeFormula
G2=B2*C2
G3=B3*C3
G4=D4*B4
G5=C5*B5
G6=D6*B6


I need get the Final value.

If Column A2 = AB then i need multiply "A2" * B2 Row.

Please help me provide VBA Macro.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
No need for a macro, you can simply use this formula
=B2*INDEX(C2:F2,MATCH(A2,$C$1:$F$1,0))
 
Upvote 0
How about
Code:
Sub smartguy()
   Dim Ary As Variant
   Dim r As Long, c As Long
   
   Ary = Range("A1").CurrentRegion.Value2
   For r = 2 To UBound(Ary)
      For c = 3 To UBound(Ary, 2) - 1
         If Ary(r, 1) = Ary(1, c) Then
            Ary(r, UBound(Ary, 2)) = Ary(r, 2) * Ary(r, c)
         End If
      Next c
   Next r
   Range("A1").Resize(UBound(Ary), UBound(Ary, 2)).Value = Ary
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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