ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Basic question: how do I change these in to functions? (https://www.excelbanter.com/excel-programming/282990-basic-question-how-do-i-change-these-functions.html)

Phillips

Basic question: how do I change these in to functions?
 
I have a cell that contains the following:
=IF(AC2<11,"A",IF(AC2<16,"B","C"))


How would I convert this into a function?

How about the following?
=OR(AND(AA2=0.333,AA2<=0.458),AND(AA2=0.6666,AA2 <=0.8953))


I think I can figure out the flow of the first one, but I am not sure how to
return the value...
I take it that the cell should have something like
=MyTestFunction()

then the functions should be something like:
Sub function MyTestFunction
if AC2 < 11
returnValue = "A"
elseif
if AC2 <16
returnValue = "B"
else
returnValue = "C"
endif
endif

end sub


TIA,
Phil







Tom Ogilvy

Basic question: how do I change these in to functions?
 
Public Function Myfunction( rng as Range)
if rng.Value < 11 then
myfunction = "A"
elseif rng.Value < 16 then
myfunction = "B"
else
myFunction = "C"
end if
End Function



=MyFunction(AC2)


"Phillips" wrote in message
news:f8Nub.245493$HS4.2174899@attbi_s01...
I have a cell that contains the following:
=IF(AC2<11,"A",IF(AC2<16,"B","C"))


How would I convert this into a function?

How about the following?
=OR(AND(AA2=0.333,AA2<=0.458),AND(AA2=0.6666,AA2 <=0.8953))


I think I can figure out the flow of the first one, but I am not sure how

to
return the value...
I take it that the cell should have something like
=MyTestFunction()

then the functions should be something like:
Sub function MyTestFunction
if AC2 < 11
returnValue = "A"
elseif
if AC2 <16
returnValue = "B"
else
returnValue = "C"
endif
endif

end sub


TIA,
Phil










All times are GMT +1. The time now is 10:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com