LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Declaring Variables

Can anybody confirm how to declare variables so that they
are accessible outside the procedure in which they had
been declared. If I use Dim, it only appears to work
within its own procedure. I also tried Static and it
doe'nt appear to work. A simplified version of the
procedures are belo. The main procedure is Transfer_Prices
which calls soln_check. Variables like
soln_count,rnum,cnum declared in Transfer_Prices do not
seem to be recognised in Soln_check.

Do the variables also have to be included in the call ie
procedure e.g. Soln_check(soln, soln_count) ?

Sub Transfer_Prices()
'
Static soln_rnum As Integer
Static soln_cnum As Integer
Static soln_count As Integer
Static rnum As Integer
Static cnum As Integer
Static soln As String

rnum = 11
cnum = 14
soln_rnum = 11
soln_cnum = 17
soln_count = 0

soln_rnum = soln_rnum + 1
If Cells(soln_rnum, soln_cnum + 2).Value < 0 Then
Soln_check (soln)
Cells(soln_rnum, soln_cnum - 1).Value = soln_count
End If
Cells(soln_rnum, soln_cnum).Select
End Sub


Sub Soln_check(soln)
Do While rnum < 30
rnum = rnum + 1
If ActiveCell.FormulaR1C1 = soln Then
soln_count = soln_count + 1
ElseIf ActiveCell.FormulaR1C1 < soln Then
Cells(rnum, cnum).Select
End If
Loop
Range("O39").Select
End Sub


 
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
Declaring variables freekrill Excel Discussion (Misc queries) 2 July 19th 06 06:36 AM
Declaring variables freekrill Excel Discussion (Misc queries) 0 July 18th 06 06:15 PM
DEclaring variables Pedro Excel Programming 1 November 13th 03 05:02 PM
Declaring variables Pedro Excel Programming 1 November 13th 03 03:32 PM
Declaring Variables chris brunt Excel Programming 2 August 4th 03 02:02 PM


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

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

About Us

"It's about Microsoft Excel"