Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Looping to create Variable Names?

Hi,

I have a whole wack of variables to name and populate and I thought it would
be appropriate to use a loop to do so. Unfortunately I'm having problems
getting it to work.

Specifically I am trying to create several variables called "VTitleBold"
with a number assigned to it which indicates the column, ie TitleBold1,
TitleBold2, TitleBold3.

So I did a count of the number of columns in question (counter) and then:

For NumberOfColumns = 1 To counter
TitleBold = "vcTitleBold" & NumberOfColumns
vcTitleBold = ActiveCell.Font.Bold
....
Next NumberOfColumns

The second line did what I wanted but was instantly replaced by the next
line.

Please help!

Thanks,

Jill E


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Looping to create Variable Names?

On Mon, 9 Aug 2004 14:11:01 -0400, "Jill E"
wrote:

Hi,

I have a whole wack of variables to name and populate and I thought it would
be appropriate to use a loop to do so. Unfortunately I'm having problems
getting it to work.

Specifically I am trying to create several variables called "VTitleBold"
with a number assigned to it which indicates the column, ie TitleBold1,
TitleBold2, TitleBold3.

So I did a count of the number of columns in question (counter) and then:

For NumberOfColumns = 1 To counter
TitleBold = "vcTitleBold" & NumberOfColumns
vcTitleBold = ActiveCell.Font.Bold
...
Next NumberOfColumns

The second line did what I wanted but was instantly replaced by the next
line.


Make it an array:
Dim VTitleBold(1 to counter) as String
For n = 1 To counter
VTitleBold(n) = ActiveCell.Font.Bold
[...]
Next
(Might have to change Dim - ReDim.)
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Looping to create Variable Names?

Thankyou! It worked!

Jill E

"Auric__" wrote in message
...
On Mon, 9 Aug 2004 14:11:01 -0400, "Jill E"
wrote:

Hi,

I have a whole wack of variables to name and populate and I thought it

would
be appropriate to use a loop to do so. Unfortunately I'm having problems
getting it to work.

Specifically I am trying to create several variables called "VTitleBold"
with a number assigned to it which indicates the column, ie TitleBold1,
TitleBold2, TitleBold3.

So I did a count of the number of columns in question (counter) and then:

For NumberOfColumns = 1 To counter
TitleBold = "vcTitleBold" & NumberOfColumns
vcTitleBold = ActiveCell.Font.Bold
...
Next NumberOfColumns

The second line did what I wanted but was instantly replaced by the next
line.


Make it an array:
Dim VTitleBold(1 to counter) as String
For n = 1 To counter
VTitleBold(n) = ActiveCell.Font.Bold
[...]
Next
(Might have to change Dim - ReDim.)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Looping to create Variable Names?

On Mon, 09 Aug 2004 11:48:41 -0700, I wrote:

Make it an array:
Dim VTitleBold(1 to counter) as String
For n = 1 To counter
VTitleBold(n) = ActiveCell.Font.Bold
[...]
Next
(Might have to change Dim - ReDim.)


Correction: if VTitleBold just holds ActiveCell.Font.Bold (a boolean
value) then dim it as boolean, not string.
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
Looping Through Names Bob Phillips[_7_] Excel Programming 0 July 27th 04 06:30 PM
Looping Through Names Tom Ogilvy Excel Programming 0 July 27th 04 06:20 PM
Create dynamic variable names? J Kruger Excel Programming 4 November 27th 03 09:41 PM
Increment a variable while looping ibeetb Excel Programming 2 September 25th 03 07:15 PM
looping to create multiple files jrh Excel Programming 1 July 23rd 03 07:09 PM


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