Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 .

<br />
Name <br />
Number<br />
Number <br />
 <br />
Anna <br />
       36.476833<br />
        7.96618557<br />
 if name = Anna Number "times Number" <br />
<br />
Eric <br />
17.451147<br />
5.80342102<br />
if name = Eric Number + Number <br />
<br />
Ronald<br />
21.125067<br />
6.45224857<br />
<br />
If name =  Ronald Number "divided"By Number <br />
<br />
Roxanne<br />
12.071469<br />
2.55927372<br />
 <br />
Harry <br />
0<br />
30.1705704<br />
 <br />
Vallerie<br />
11.67783<br />
0<br />
 <br />
Wally <br />
0<br />
6.81271219<br />
 <br />
Posted
Comments
Maciej Los 15-Dec-13 14:13pm    
Sorry, but your question is completely not understandable..
Please, be more specific and provide more details, for example code sample...
Raja Sekhar S 15-Dec-13 23:31pm    
Provide some sample data... u can use find function...

1 solution

Hi
For i = 2 To 100 <------ this value is the range to lookup on column 1
If Sheet(?).Cells(i, 1) = "Anna" Then <------ execute the following code where i is true.
Sheet(?).Cells(i, 4).Value = Sheet(?).Cells(i, 2).Value +Sheet(?).Cells(i, 3).Value
End If

* Add your next if statements here
* Sheet(?) The ? must be replaced by the sheet name you are using ie: Sheet(1)
Next i
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900