#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Public Variables

I have the floolwing macro which is always run as the first procedure in my
application:

Option Explicit
Public intRecordRow As Integer
Public intRecordCol As Integer


Sub Clear()

Sheets("Columns").Select
Range("A1:I9").Select
Selection.ClearContents
Selection.Interior.ColorIndex = 15

Range("L1:AQ29").Select
Selection.Interior.ColorIndex = 37

Range("J32:AJ34").Select
Selection.ClearContents

Sheets("Rows").Select
Range("A1:I9").Select
Selection.Interior.ColorIndex = 15
Range("L1:AQ29").Select
Selection.Interior.ColorIndex = 37
Sheets("Areas").Select
Range("A1:I9").Select
Selection.Interior.ColorIndex = 15
Range("L1:AQ29").Select
Selection.Interior.ColorIndex = 37

intRecordRow = 32
intRecordCol = 11

End Sub

'
This seems to work just fine and intRecordRow is 32 and intRecordDol is 11.
I then run the following module:

Sub Load()

Dim intColor As Integer
Dim strCell As String
Dim strValue As String
Dim strRef As String

intColor = Worksheets("Columns").Cells(14, 2).Interior.ColorIndex
strCell = Application.InputBox(prompt:="Select a cell", Type:=2)

strValue = Application.InputBox(prompt:=("Enter a value for " &
strCell), Type:=1)

Worksheets("Columns").Range(strCell).Value = strValue
Worksheets("Columns").Range(strCell).Interior.Colo rIndex = intColor
Worksheets("Rows").Range(strCell).Interior.ColorIn dex = intColor
Worksheets("Areas").Range(strCell).Interior.ColorI ndex = intColor

strRef = Worksheets("ColumnList").Range(strCell).Value
Worksheets("Columns").Range(strRef).Interior.Color Index = intColor

strRef = Worksheets("RowList").Range(strCell).Value
Worksheets("Rows").Range(strRef).Interior.ColorInd ex = intColor

strRef = Worksheets("AreaList").Range(strCell).Value
Worksheets("Areas").Range(strRef).Interior.ColorIn dex = intColor

Worksheets("Columns").Range(intRecordCol, intRecordRow).Value = strCell
intRecordCol = intRecordCol + 1
If intRecordCol 37 Then
intRecordRow = intRecordRow + 1
intRecordCol = 11
End If

End Sub

By the time I reach the references to the public variables, both have been
set to zero.
' Clear Macro
' Clear for a new game
'
' Keyboard Shortcut: Ctrl+d
'

Sheets("Columns").Select
Range("A1:I9").Select
Selection.ClearContents
Selection.Interior.ColorIndex = 15

Range("L1:AQ29").Select
Selection.Interior.ColorIndex = 37

Range("J32:AJ34").Select
Selection.ClearContents

Sheets("Rows").Select
Range("A1:I9").Select
Selection.Interior.ColorIndex = 15
Range("L1:AQ29").Select
Selection.Interior.ColorIndex = 37
Sheets("Areas").Select
Range("A1:I9").Select
Selection.Interior.ColorIndex = 15
Range("L1:AQ29").Select
Selection.Interior.ColorIndex = 37

intRecordRow = 32
intRecordCol = 11

End Sub

By the time I try to use the public variables, both have been set to zero.
What happened? Can someone please help? Thank you.

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
Declaring variables in Module vs. Public Jeff Excel Discussion (Misc queries) 5 November 19th 07 08:27 PM
Public Password Excel 2003 - SPB Excel Discussion (Misc queries) 2 May 23rd 07 11:08 PM
Using A Public Function / carl Excel Worksheet Functions 1 April 6th 06 09:13 PM
Public variable Jack New Users to Excel 4 March 18th 06 09:35 PM
Public Curiosity BillCPA Excel Discussion (Misc queries) 1 December 5th 05 10:33 PM


All times are GMT +1. The time now is 04:12 PM.

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"