VBA Express Forum  




Go Back   VBA Express Forum > VBA Code & Other Help > Excel Help
     Feedback     
Register FAQ Members Arcade Knowledge Base Training Articles Consulting

Reply
 
Thread Tools Display Modes
Old 04-30-2012, 09:34 AM   #1
chineth

 
Joined: Jun 2011
Posts: 2
Kb Entries: 0
Articles: 0
Solved: Build Dynamic String into Cell

Hi,

I am trying to go through a list of items and have them be stored in a dynamic array. Then that list would look like 'A, B, C, D'... in a specified cell. I'm not sure how to make a string 'dynamic'.

I have this code so far for 20 at a time:

Code:
Dim arr(1 To 20) As Variant, rng As Range, id As String, rng2 As Range Range("b2").Activate Do Until IsEmpty(ActiveCell) For i = 1 To 20 '20 If i = 1 Then Set rng = ActiveCell.Offset(0, 1) End If arr(i) = ActiveCell.Value ActiveCell.Offset(1, 0).Activate Next i Set rng2 = ActiveCell id = arr(1) + ", " + arr(2) + ", " + arr(3) + ", " + arr(4) + ", " + arr(5) + ", " + arr(6) + ", " + arr(7) + ", " + arr(8) + ", " + arr(9) + ", " + arr(10) + ", " + arr(11) + ", " + arr(12) + ", " + arr(13) + ", " + arr(14) + ", " + arr(15) + ", " + arr(16) + ", " + arr(17) + ", " + arr(18) + ", " + arr(19) + ", " + arr(20) rng.Value = id Loop

Clearly, this hardcode is not adaptable, so how could this to a nonspecified number?

Thank you for your input!

Local Time: 03:30 PM
Local Date: 05-24-2013
Location:

 
Reply With Quote Top
Old 04-30-2012, 10:55 AM   #2
Kenneth Hobs
 
Kenneth Hobs's Avatar

 
Joined: Nov 2005
Posts: 2,850
Kb Entries: 2
Articles: 0
Look at Join().

Local Time: 02:30 PM
Local Date: 05-24-2013
Location:

 
Reply With Quote Top
Old 04-30-2012, 11:16 AM   #3
chineth

 
Joined: Jun 2011
Posts: 2
Kb Entries: 0
Articles: 0
Thanks! Figured it out.

Local Time: 03:30 PM
Local Date: 05-24-2013
Location:

 
Reply With Quote Top
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 12:30 PM.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2012 VBA Express