Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default String Array initialisation



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
.....

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default String Array initialisation

This will work:

Dim VarNames

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

RBS



wrote in message
oups.com...


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
 ....



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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default String Array initialisation

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


wrote:

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
 ....
 


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

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
String array initialisation [email protected] Excel Programming 2 June 29th 06 09:20 PM
DTPicker to be dropped down on initialisation WhytheQ Excel Programming 1 June 8th 06 08:54 PM
String array issues. Need help... John Guderian Excel Programming 1 August 12th 05 08:00 PM
How to avoid re-initialisation when Unloading form count Excel Programming 4 December 14th 04 03:58 PM
Passing a String in Array to Range as String [email protected] Excel Programming 2 September 1st 04 01:13 AM


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