Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AL AL is offline
external usenet poster
 
Posts: 37
Default Variabilized Variable

is there a way for me to make the following procedure work?
As I go through the loop each time, i'd like the
messagebox to pop up with the value denoted by
the variable. So the first time i go through,
the message TWO should pop up in the messagebox.
Thanks in advance.


SUB TEST
DIM M1,M2,M3 AS STRING
dim x as integer

M1="TWO"
M2="THREE"
M3="FOUR"

FOR X = 1 TO 3
MSGBOX "M"& X

NEXT X

END SUB
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Variabilized Variable

SUB TEST
DIM M(1 to 3) as String
dim x as integer

M(1)="TWO"
M(2)="THREE"
M(3)="FOUR"

FOR X = 1 TO 3
MSGBOX M(X)

NEXT X

END SUB

--
Regards,
Tom Ogilvy

"Al" wrote in message
...
is there a way for me to make the following procedure work?
As I go through the loop each time, i'd like the
messagebox to pop up with the value denoted by
the variable. So the first time i go through,
the message TWO should pop up in the messagebox.
Thanks in advance.


SUB TEST
DIM M1,M2,M3 AS STRING
dim x as integer

M1="TWO"
M2="THREE"
M3="FOUR"

FOR X = 1 TO 3
MSGBOX "M"& X

NEXT X

END SUB



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Variabilized Variable

Create an array:

Sub TEST()
Dim M1, M2, M3 As String
Dim x As Integer
Dim m(20) As Variant
m(1) = "TWO"
m(2) = "THREE"
m(3) = "FOUR"

For x = 1 To 3
MsgBox (m(x))
Next
End Sub

Carl

"Al" wrote in message
...
is there a way for me to make the following procedure work?
As I go through the loop each time, i'd like the
messagebox to pop up with the value denoted by
the variable. So the first time i go through,
the message TWO should pop up in the messagebox.
Thanks in advance.


SUB TEST
DIM M1,M2,M3 AS STRING
dim x as integer

M1="TWO"
M2="THREE"
M3="FOUR"

FOR X = 1 TO 3
MSGBOX "M"& X

NEXT X

END SUB



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Variabilized Variable

OR:

Sub xx
dim item as variant
for each item in Array("TWO","THREE","FOUR")
MsgBox item
next
End Sub

' You can add or remove items from the Array list a will.

"Al" wrote:

is there a way for me to make the following procedure work?
As I go through the loop each time, i'd like the
messagebox to pop up with the value denoted by
the variable. So the first time i go through,
the message TWO should pop up in the messagebox.
Thanks in advance.


SUB TEST
DIM M1,M2,M3 AS STRING
dim x as integer

M1="TWO"
M2="THREE"
M3="FOUR"

FOR X = 1 TO 3
MSGBOX "M"& X

NEXT X

END SUB

  #5   Report Post  
Posted to microsoft.public.excel.programming
AL AL is offline
external usenet poster
 
Posts: 37
Default Variabilized Variable

Thanks Tom!! Hadn't thought about using an array.
-----Original Message-----
SUB TEST
DIM M(1 to 3) as String
dim x as integer

M(1)="TWO"
M(2)="THREE"
M(3)="FOUR"

FOR X = 1 TO 3
MSGBOX M(X)

NEXT X

END SUB

--
Regards,
Tom Ogilvy

"Al" wrote in

message
...
is there a way for me to make the following procedure

work?
As I go through the loop each time, i'd like the
messagebox to pop up with the value denoted by
the variable. So the first time i go through,
the message TWO should pop up in the messagebox.
Thanks in advance.


SUB TEST
DIM M1,M2,M3 AS STRING
dim x as integer

M1="TWO"
M2="THREE"
M3="FOUR"

FOR X = 1 TO 3
MSGBOX "M"& X

NEXT X

END SUB



.

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
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


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