ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro help (https://www.excelbanter.com/excel-discussion-misc-queries/72555-macro-help.html)

jwfakouri

macro help
 

hey guys'
need help writing this formula as a macro, i need to nest an
infinite number of
packs
=IF(B1="2pack",H1/4,IF(B1="3
packl",H1/15,IF(B1="4 pack",H1/15,"not")))

thanks
jason


--
jwfakouri
------------------------------------------------------------------------
jwfakouri's Profile: http://www.excelforum.com/member.php...o&userid=31435
View this thread: http://www.excelforum.com/showthread...hreadid=514024


Kassie

macro help
 
Hi

Why don't you create a table with all your packs and division factors, and
then use Vlookup to retrieve same?

"jwfakouri" wrote:


hey guys'
need help writing this formula as a macro, i need to nest an
infinite number of
packs
=IF(B1="2pack",H1/4,IF(B1="3
packl",H1/15,IF(B1="4 pack",H1/15,"not")))

thanks
jason


--
jwfakouri
------------------------------------------------------------------------
jwfakouri's Profile: http://www.excelforum.com/member.php...o&userid=31435
View this thread: http://www.excelforum.com/showthread...hreadid=514024



Jim Cone

macro help
 
jason,
Maybe something like this...

'----------------------------------
Function WhackAMole() As Double
Dim strName As String
Dim dblValue As Double
Dim dblAnswer As Double
strName = Range("B1").Text
dblValue = Range("H1").Value2

Select Case strName
Case "2pack"
dblAnswer = dblValue / 4
Case "3pack"
dblAnswer = dblValue / 15
Case "4pack"
dblAnswer = dblValue / 15
'enter as many more as you need...
Case Else
dblAnswer = 0
End Select

WhackAMole = dblAnswer
End Function
'------------------------------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"jwfakouri" wrote in message
hey guys'
need help writing this formula as a macro, i need to nest an
infinite number of
packs
=IF(B1="2pack",H1/4,IF(B1="3
packl",H1/15,IF(B1="4 pack",H1/15,"not")))

thanks
jason
jwfakouri



All times are GMT +1. The time now is 06:01 AM.

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