Macro IF,AND. How to?

Maci3j

Board Regular
Joined
Apr 4, 2013
Messages
85
Office Version
  1. 365
Dear readers,

Im an amateur in making macros and I cant menage to make a valid macro for the fallowing case which will easy my work a lot. So may I ask you to give me an example of the formula from beginning to the end?What I'm searching is a formula for:

"Score" (is the name of the column) is located in cell H9 and the values (the scores) are located in a range (H10:H1577).

If the values in the range H10:H1577 are >=1 and <=10 then "Group1" should appear in the cell where i put the formula. But not a messagebox.

If the values in the range H10:H1577 are >=11 and <=30 then "Group2" should appear in the cell where i put the formula. But not a messagebox.

Thanks in advance
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
try the formula:
=if(And(H10>=1,H10<=10),"Group1",if(and(H10>=11,H10<=30),"Group2","Group3"))

If you have many more groups than this, you should probably make a little lookup table like:

0Group0
1Group1
11Group2
31Group3
51Group4

<tbody>
</tbody>

=vlookup(H10,Groups!A1:B5,2)
 
Upvote 0

Forum statistics

Threads
1,203,502
Messages
6,055,772
Members
444,822
Latest member
Hombre

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