Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 295
Default variable nam in VB

I've specified
Dim mem1, mem2, mem3
counter = 1

and I want to run through a loop such as
Do while counter <= 3
Msgbox "Name = " & mem & counter
counter = counter + 1
Loop

to show 3 Msgboxes, but VB doesn't like "mem & counter".

How do I express "mem & counter please?
Also, what do you actually call things like mem1, mem2? Are they simply
called dimensions or..........
Regards, Bret

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default variable nam in VB

not sure what you're trying to do, but maybe this will help

Sub test()
Dim mem(3) As String
Dim counter As Long

Do While counter <= 2
MsgBox "Name = " & mem(counter) & counter
counter = counter + 1
Loop
End Sub

--


Gary

"Brettjg" wrote in message
...
I've specified
Dim mem1, mem2, mem3
counter = 1

and I want to run through a loop such as
Do while counter <= 3
Msgbox "Name = " & mem & counter
counter = counter + 1
Loop

to show 3 Msgboxes, but VB doesn't like "mem & counter".

How do I express "mem & counter please?
Also, what do you actually call things like mem1, mem2? Are they simply
called dimensions or..........
Regards, Bret


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 295
Default variable nam in VB

Thanks very much Gary, that was exactly what I needed. Brett

"Gary Keramidas" wrote:

not sure what you're trying to do, but maybe this will help

Sub test()
Dim mem(3) As String
Dim counter As Long

Do While counter <= 2
MsgBox "Name = " & mem(counter) & counter
counter = counter + 1
Loop
End Sub

--


Gary

"Brettjg" wrote in message
...
I've specified
Dim mem1, mem2, mem3
counter = 1

and I want to run through a loop such as
Do while counter <= 3
Msgbox "Name = " & mem & counter
counter = counter + 1
Loop

to show 3 Msgboxes, but VB doesn't like "mem & counter".

How do I express "mem & counter please?
Also, what do you actually call things like mem1, mem2? Are they simply
called dimensions or..........
Regards, Bret



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
Nothing Keyword Destories Objects rather than just resetting the variable to an empty variable Ronald R. Dodge, Jr.[_2_] Excel Programming 15 December 15th 08 09:19 PM
Running a variable macro when any value is entered into a variable cell [email protected] Excel Programming 3 December 14th 05 05:15 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
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 11:03 PM.

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"