Looping through Column Finding Name then Proceeding with a function VBA Excel

ericmax79

New Member
Joined
Dec 13, 2013
Messages
37
I have a excel Where i Have 6 different names as variables . The varibles are dynamic . They end up in different rows everytime i do this function . Can someone please help me on how to go about Looping through these names . Finding out which name is which . then performing a different calculation depending on what the "name " is . The names always end up in Column A . They just end up in different rows . So i would like to know how to do a function /macro that looks like this ....... If name = Anna d1=b1*c1 . If name = Harry d1 = b1+c1 ....... Thank you guys . I am new to excel




Code:
[TABLE="width: 604"]
<colgroup><col><col><col><col><col></colgroup><tbody>[TR]
[TD]Name 
[/TD]
[TD]Number
[/TD]
[TD]Number 
[/TD]
[TD="colspan: 2"] 
[/TD]
[/TR]
[TR]
[TD]Anna
[/TD]
[TD]36.476833
[/TD]
[TD]7.96618557
[/TD]
[TD="colspan: 2"]if name = Anna Number "times Number"
[/TD]
[/TR]
[TR]
[TD]Eric 
[/TD]
[TD]17.451147
[/TD]
[TD]5.80342102
[/TD]
[TD="colspan: 2"]if name = Eric Number = Number 
[/TD]
[/TR]
[TR]
[TD]Ronald
[/TD]
[TD]21.125067
[/TD]
[TD]6.45224857
[/TD]
[TD]If name = Ronald Number "divided"By Number 
[/TD]
[TD]

[/TD]
[/TR]
[TR]
[TD]Roxanne
[/TD]
[TD]12.071469
[/TD]
[TD]2.55927372
[/TD]
[TD="colspan: 2"] 
[/TD]
[/TR]
[TR]
[TD]Harry 
[/TD]
[TD]0
[/TD]
[TD]30.1705704
[/TD]
[TD="colspan: 2"] 
[/TD]
[/TR]
[TR]
[TD]Vallerie
[/TD]
[TD]11.67783
[/TD]
[TD]0
[/TD]
[TD="colspan: 2"] 
[/TD]
[/TR]
[TR]
[TD]Wally 
[/TD]
[TD]0
[/TD]
[TD]6.81271219
[/TD]
[TD="colspan: 2"] 
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You have seven names there. What do you want to do for Roxanne, Harry, Vallerie and Wally?


Any Function would Work Andrew ....... - + or * ..... I dont have those variables yet . The fact you could help me with the "structure" would be huge ....... Could I possible fill those parts in there after ? You can "add" them for this example would be absolutely appreciated. Thank You Sir
Eric Maxfield
 
Upvote 0
this is probably not the most efficient way to do it, but a nested IF statement will accomplish the 4 tasks you listed in your first question, however Andrew brings up a good question how many more functions do you want and what do you want done with the other names. in this case I left them blank "". Don =IF(A1="Anna",B1*C1,IF(A1="Eric",B1,IF(A1="Ronald",B1/C1,IF(A1="Harry",B1+C1,""))))
 
Upvote 0
this is probably not the most efficient way to do it, but a nested IF statement will accomplish the 4 tasks you listed in your first question, however Andrew brings up a good question how many more functions do you want and what do you want done with the other names. in this case I left them blank "". Don =IF(A1="Anna",B1*C1,IF(A1="Eric",B1,IF(A1="Ronald",B1/C1,IF(A1="Harry",B1+C1,""))))


Thank You Drrellik :) I would like to Add them for this example as if they were "harry" but with different names . I am so New to this stuff . So bear with me .. I would like "d1" TO Equal these Different functions all the way down to the end of the Rows . Around 50 rows . I understand "nested if Stament . But where should i apply it to? D1 all the way down ? ...Do you have advice for a macro that i could run ? Is that what your talking about in regaurde to be "more efficieint " Rather than ....Less effiecient ... Thank you very much Andrew And Dreellik. I ask for a macro . Because this sheet i am referiing to is a blank worksheet . That gets Cleared everytime for a new "user " Thank you very Much Sirs
 
Upvote 0
If this is a sheet that gets cleared with every new user, then you will need VBA, and for that I will Demure to Andrew or someone else, as I am not proficient in VBA. Don
 
Upvote 0
If this is a sheet that gets cleared with every new user, then you will need VBA, and for that I will Demure to Andrew or someone else, as I am not proficient in VBA. Don


Andrew could you help me Possibly I redid the code to make it easier Thank you so Much Regards Eric Maxfield

Code:
[TABLE="class: cms_table, width: 604"]
<tbody>[TR]
[TD]Name [/TD]
[TD]Number[/TD]
[TD]Number [/TD]
[TD="colspan: 2"][/TD]
[/TR]
[TR]
[TD]Anna[/TD]
[TD]36.476833[/TD]
[TD]7.96618557[/TD]
[TD="colspan: 2"]if name = Anna Number "times Number"[/TD]
[/TR]
[TR]
[TD]Eric [/TD]
[TD]17.451147[/TD]
[TD]5.80342102[/TD]
[TD="colspan: 2"]if name = Eric Number+ Number [/TD]
[/TR]
[TR]
[TD]Ronald[/TD]
[TD]21.125067[/TD]
[TD]6.45224857[/TD]
[TD]If name = Ronald Number "divided"By Number
 
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Roxanne[/TD]
[TD]12.071469[/TD]
[TD]2.55927372[/TD]
[TD="colspan: 2"]if name = Roxanne Number+ Number[/TD]
[/TR]
[TR]
[TD]Harry [/TD]
[TD]0[/TD]
[TD]30.1705704[/TD]
[TD="colspan: 2"]if name = Harry Number+ Number[/TD]
[/TR]
[TR]
[TD]Vallerie[/TD]
[TD]11.67783[/TD]
[TD]0[/TD]
[TD="colspan: 2"]if name = Valerie Number+ Number[/TD]
[/TR]
[TR]
[TD]Wally [/TD]
[TD]0[/TD]
[TD]6.81271219             if name = Wally  Number+ Number

[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,225,490
Messages
6,185,294
Members
453,285
Latest member
Wullay

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