Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok, any perceptive people out there have realised that I'm bashing my way
through this VBA with brute force & ignorance, but I'm now trying to streamline it. I have this sub below: Private Sub SpinTaxIR4_Change() If SpinTaxIR4 -1 And SpinTaxIR4 < 5 Then txtIR4 = "$" & (SpinTaxIR4 * Sheets(1).Range("B3")) & ".00" Else txtIR4 = "Enter Special Quote Here." End If End Sub The problem is that I have to do this same procedure several times, but with SpinTaxIR3, SpinTaxIR5 etc and differing cell references. How do I create a generic routine that I can call similar to this? Private Sub SpinTaxIR4_Change() Range = Sheets(1).Range("B2") Call taxCalc End Sub Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bobodd:
Try this: Private function taxChange(szSpinTaxIR as string, sAmt as string) as string dim SpinTaxIR as integer SpinTaxIR= cint(szSpinTaxIR) If SpinTaxIR -1 And TaxIR < 5 Then taxChange= "$" & (SpinTaxIR * cdbl(Amt)) & ".00" Else taxChange = "Enter Special Quote Here." End If End Sub Private Sub SpinTaxIR4_Change() me.txtIR4 = taxChange(me.SpinTaxIR4.value, _ Sheets(1).Range("B3").value)) End Sub -- Hope this helps Martin Fishlock "BOBODD" wrote: Ok, any perceptive people out there have realised that I'm bashing my way through this VBA with brute force & ignorance, but I'm now trying to streamline it. I have this sub below: Private Sub SpinTaxIR4_Change() If SpinTaxIR4 -1 And SpinTaxIR4 < 5 Then txtIR4 = "$" & (SpinTaxIR4 * Sheets(1).Range("B3")) & ".00" Else txtIR4 = "Enter Special Quote Here." End If End Sub The problem is that I have to do this same procedure several times, but with SpinTaxIR3, SpinTaxIR5 etc and differing cell references. How do I create a generic routine that I can call similar to this? Private Sub SpinTaxIR4_Change() Range = Sheets(1).Range("B2") Call taxCalc End Sub Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
General | Excel Discussion (Misc queries) | |||
referencing a different tab by referencing a list in the current s | Excel Worksheet Functions | |||
Referencing a specific number to more general values in a table. | Excel Worksheet Functions | |||
Format: General - Text - General | Excel Worksheet Functions | |||
Referencing a general Cell(i,j) in an Add-In | Excel Programming |