Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Adding a counter to a variable name

I will be collecting values from multiple sheets.

How do I create a variable name with a counter attached to it, and how do I
declare that variable.

For example, I want variable names to be "DkType1", "DkType2", etc. I don't
know how many "DkType"s I will have.

Thanks!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Adding a counter to a variable name

You probably want an array...

Sub stuff()
Dim DKType() As Variant
Dim lng As Long

ReDim DKType(lng)
DKType(lng) = Range("A1").Value
lng = lng + 1
ReDim Preserve DKType(lng)
DKType(lng) = Range("A2").Value
lng = lng + 1
ReDim Preserve DKType(lng)
DKType(lng) = Range("A3").Value

For lng = LBound(DKType) To UBound(DKType)
MsgBox DKType(lng)
Next lng

Range("C1:C3").Value = Application.Transpose(DKType) 'write the array
End Sub

--
HTH...

Jim Thomlinson


"Rich" wrote:

I will be collecting values from multiple sheets.

How do I create a variable name with a counter attached to it, and how do I
declare that variable.

For example, I want variable names to be "DkType1", "DkType2", etc. I don't
know how many "DkType"s I will have.

Thanks!!!

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
Adding counter to new worksheet [email protected] Excel Programming 1 April 6th 07 01:49 PM
Counter variable and a multiplier LenS Excel Discussion (Misc queries) 1 February 23rd 07 11:50 AM
Adding a counter to ranges wmureports Excel Programming 2 June 29th 06 06:40 PM
Counter variable in For Loop [email protected] Excel Programming 3 June 8th 06 06:56 PM
variable counter/total Carole Excel Programming 1 October 20th 03 07:23 AM


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