Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
General Ken Excel Discussion (Misc queries) 1 November 30th 07 08:39 PM
referencing a different tab by referencing a list in the current s Kevin Excel Worksheet Functions 3 July 6th 07 07:57 PM
Referencing a specific number to more general values in a table. AJL Excel Worksheet Functions 0 September 19th 06 05:11 PM
Format: General - Text - General iturnrocks Excel Worksheet Functions 3 August 11th 06 04:47 PM
Referencing a general Cell(i,j) in an Add-In Damo Excel Programming 1 November 9th 04 02:16 AM


All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"