Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / June 2006

Tip: Looking for answers? Try searching our database.

String Array initialisation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
major_yash@yahoo.com - 29 Jun 2006 21:02 GMT
Hi,

I am facing a problem in intialising a string array in VBA. I need to
intialise an array of 10 elements from data in a range. This range has
text values. I tried to use following.

[code]

Dim VarNames() As String
....
VarNames = ActiveSheet.Range("K22:K32").Value
....

[/code]

But I am getting Type Mismatch error. I don't want to use any loop to
populate the array. Filling each value is cumbersome.

Can anybody please suggest some way around.

Thanks,

Mhr
RB Smissaert - 29 Jun 2006 21:47 GMT
This will work:

Dim VarNames

VarNames = ActiveSheet.Range("K22:K32").Value

RBS

> Hi,
>
[quoted text clipped - 19 lines]
>
> Mhr
Alan Beban - 30 Jun 2006 21:59 GMT
If it is unacceptable for VarNames to be of Variant() type (which is
what the other replies in this thread have provided), then if the
functions in the freely downloadable file at
http:/home.pacbell.net/beban are available to your workbook

Sub test2()
    Dim VarNames() As String
    Assign ActiveSheet.Range("K22:K32"), VarNames
End Sub

Alan Beban

> Hi,
>
[quoted text clipped - 19 lines]
>
> Mhr
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.