View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Stewart[_3_] Stewart[_3_] is offline
external usenet poster
 
Posts: 8
Default Finding closest value within an array

Easy when you know how - cheers, that's given me an idea
on how to do the other part of the problem I've got too -
nice one.

Stewart


-----Original Message-----

A=90% and above
B=80% and above
C=70% and above

I've got 10000 pupils with varying results is there any
macro I can create to give each pupil a grade for their
result and put it on a worksheet (I would use formulas

but


range("A65536").select ' this bit finds the last

row which contains
data
activecell.end(xlUp).select
lastrow = activecell.row

with sheets("Sheet1") 'or whatever your sheet is called
for r = 1 to lastrow
mark = .cells( r,

2).value 'looking for mark in
column 2 (i.e. B)
if mark = 90 then
grade = "A"
elseif mark = 80 then
grade = "B"
elseif mark = 70 then
grade = "C"
else
grade = "D"
endif
.cells( r, 3).value = grade 'write

value into column
3 (i.e. C)
next
end with

Iain King


.