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


Jonas

Public declarations do not go inside macro's

It is also a good idea to declare all variables that you wish to use

I suggest having a look at http://www.cpearson.com/ especially
http://www.cpearson.com/excel/variables.htm

In regards to your code try this

Sub test()
Dim counter As Integer
For counter = 1 To 30
Range("B1").Select
testme(counter) = Selection.Offset(counter, 0)
Next counter
End Sub

Sub test2()
Dim counter2 As Integer
For counter2 = 1 To 30
If testme(counter2) = 1 Then testme(counter2) = testme(counter2) - 1
MsgBox counter2
Next counter2
End Sub

You can use the same variables names within different macros
as an example

Sub test()
Dim counter As Integer
For counter = 1 To 30
Range("B1").Select
testme(counter) = Selection.Offset(counter, 0)
Next counter
End Sub

Sub test2()
Dim counter As Integer
For counter = 1 To 30
If testme(counter) = 1 Then testme(counter) = testme(counter) - 1
MsgBox counter
Next counter
End Sub

If you need to declare a public variable then it would be done as

Public testme(1 To 30) As Integer

Sub test()
Dim counter As Integer
For counter = 1 To 30
Range("B1").Select
testme(counter) = Selection.Offset(counter, 0)
Next counter
End Sub

Sub test2()
Dim counter As Integer
For counter = 1 To 30
If testme(counter) = 1 Then testme(counter) = testme(counter) - 1
MsgBox counter
Next counter
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=518097

 
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
Manipulating dates Peter Excel Discussion (Misc queries) 5 October 26th 07 05:36 PM
manipulating cells with symbols and numbers [email protected] Excel Worksheet Functions 5 February 1st 07 09:33 PM
Manipulating clipboard? [email protected] Excel Programming 1 September 23rd 05 01:05 PM
Manipulating Strings Leslie Coover Excel Programming 2 July 27th 05 06:45 AM
Manipulating DOS from VBA Dave Peterson[_3_] Excel Programming 0 October 17th 03 01:46 AM


All times are GMT +1. The time now is 12:39 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"