ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using 'i' to calculate public variables (https://www.excelbanter.com/excel-programming/397889-using-i-calculate-public-variables.html)

baptism by fire

Using 'i' to calculate public variables
 
If anyone can help me out:

I've written some code that uses public variables and the values transfer
fine from one sub to the next when placed in sequence. But for some reason I
can't get a set of variables to transfer to another sub when I perform
calculations were I'm selecting the variable name with the 'i' variable.

I'm going to past in the variables declared and the sub that's not working
properly. Could a more knowledgeable person tell me what's breaking down?
Thank you.

Public Row_Constant As Integer
Public Spacer As Integer
Public Stores_Per_Graph_1 As String
Public Stores_Per_Graph_2 As String
Public Stores_Per_Graph_3 As String
Public Stores_Per_Graph_4 As String
Public Number_of_Graphs As String
Public Store_Count As Integer
Public i As Integer

Sub GET_STORES_PER_GRAPH()

Number_of_Graphs = 2
Store_Count = 29

Dim a As Integer
Dim Stores_Used As Integer

a = 0
i = 1

MsgBox ("This is " & Stores_Per_Graph_i)

Do

Stores_Per_Graph_i = Ceiling((Store_Count - Stores_Used) / (Number_of_Graphs
- a))
Stores_Used = Stores_Used + Stores_Per_Graph_i

MsgBox ("This is " & Stores_Per_Graph_i)

i = i + 1
a = a + 1
Loop Until (Number_of_Graphs - a) = 0

End Sub

Sub GET_STORES_PER_GRAPH_1 ()

MsgBox ("This is " & Stores_Per_Graph_i)

End Sub


baptism by fire[_2_]

Using 'i' to calculate public variables
 
Thank you. I tried to simplify my problem by isolating the code that was
giving me problems, but after you answered I realized that I hadn't included
everything to make that code function. At any rate, thank you - that works.


All times are GMT +1. The time now is 11:09 AM.

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