Reposting IF,AND, THEN

joacro

Board Regular
Joined
Jun 24, 2010
Messages
158
Hi there,

I am reposting this again as I did not get a answer that worked on the previous post and I thing it went dead.


I need VBA code for:

If Range(F2)greater or equal to 90000 and (H2) = 90000 the (J2) ="Gold'
else if (F2) = smaller than 90000 but greater or equl to 70000 and H2 = 90000 the H2 = Silver


Hope this makes sense and that someone can help me

Regards
Joacro
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Do you really need code rather than a formula for some reason?
 
Upvote 0
Like this?

Code:
If Range("H2") = 90000 Then
    If Range("F2") >= 90000 Then Range("J2") = "Gold"
    If Range("F2") >= 70000 Then Range("H2") = "Silver"
End If
 
Upvote 0
Code:
=IF(AND(F2>=90000,H2=90000),"Gold",IF(AND(F2<90000,F2>=70000,H2=90000),"Silver","other"))

You've not said what you want to do if neither of the conditions you've mentioned are true, so I've added a catch all of "other" at the end of the formula.
 
Upvote 0
Hi there,

I defnitely need code, as I need to do this with Blue and Bronze as well and every one has 2 or more conditions. And also different vallues

None of the code seem to be working.

1. If H3 = "90000" and G3 =>90000 then I3 = "Gold"
2. If H3 = "90000" and G3 <90000 but =>70000 then I3 = Silver
3. If H3 = "90000" and G3 <70000 but =>45000 then I3 = Bronze
4. If H3 = "90000" and G3 <45000 then I3 = Blue

5. If H3 = "120000" and G3 =>120000 then I3 = "Gold"
6. If H3 = "120000" and G3 <120000 but =>90000 then I3 = Silver
7. If H3 = "120000" and G3 <120000 but =>70000 then I3 = Bronze
8. If H3 = "120000" and G3 <700000 then I3 = Blue

etc

Hope the above make any sense.

Regards
 
Upvote 0
Is H3 text or numbers ?
You are currently suggesting that it is text, which could be part of your problem
H3 = "90000"
 
Upvote 0
Maybe something like
Code:
Sub medal()
ans = InputBox("What Value is in H3")
   Range("H3").value = ans
If ans = 90000 Then
    If Range("G3").Value >= 90000 Then Range("I3").Value = "Gold"
    If Range("G3").Value < 90000 And Range("G3").Value >= 70000 Then Range("I3").Value = "Silver"
    If Range("G3").Value < 70000 And Range("G3").Value >= 45000 Then Range("I3").Value = "Bronze"
    If Range("G3").Value < 45000 Then Range("I3").Value = "Blue"
ElseIf ans = 120000 Then
    If Range("G3").Value >= 120000 Then Range("I3").Value = "Gold"
    If Range("G3").Value < 120000 And Range("G3").Value >= 90000 Then Range("I3").Value = "Silver"
    If Range("G3").Value < 90000 And Range("G3").Value >= 70000 Then Range("I3").Value = "Bronze"
    If Range("G3").Value < 70000 Then Range("I3").Value = "Blue"
End If
End Sub
 
Last edited:
Upvote 0
????
The code supplied is for numbers
 
Upvote 0
Hi Michael,

I just cant seem to get it to work.

Must be doing someting wrong. I pasted the code on the sheet that requires the formulas.

Also I replace "H" with "I" and "I with "K"
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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