![]() |
General referencing
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. |
General referencing
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. |
All times are GMT +1. The time now is 12:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com