473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Excel Array issues

maxamis4
295 Expert 100+
I keep getting a runtime error when I try to add a value to my array. The error is Run-time error '9' Subscript out of range.

I am pretty sure i have declared everything correctly but can't see to figure out whats wrong. Also the array should store string values.


Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim myarr As Variant
  3. Dim c, r As Integer
  4. Dim tbl As ListObject
  5. Dim cl As Range, Rng As Range
  6.  
  7.  
  8.     Worksheets("tblINR144").Activate
  9.  
  10.     Set tbl = ActiveSheet.ListObjects("Table3")
  11.  
  12.     With tbl.DataBodyRange
  13.         tRows = .Rows.count
  14.         tCols = .Columns.count
  15.     End With
  16.  
  17.  
  18.     Set Rng = Range("A1:x" & tRows & "")
  19.  
  20.  
  21. ReDim myarr(0 To tRows, 1 To tRows, 2 To tRows) As String
  22.  
  23.     c = 1
  24.  
  25.     For Each cl In Rng.SpecialCells(xlCellTypeVisible)
  26.         Dim t As Integer
  27.  
  28.  
  29.         'GET EMPLOYEE NAME
  30.         If cl.Column = 8 And cl.Row > 1 Then
  31.  
  32.           myarr(0, c) = cl'error here
  33.  
  34.             c = c + 1
  35.  
  36.         End If
  37.  
  38.     Next cl
  39.  
  40.  
  41.  
Dec 31 '16 #1
1 2341
maxamis4
295 Expert 100+
I solved the problem. I had declared the array incorrectly. I only needed to declare two-dimensional array versus three.
Jan 3 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Robbie Hatley | last post by:
About 20 days ago, "John Harrison" <john_andronicus@hotmail.com> replied to a message which I had written: > > > Q1 . What is the use of pointer to an array? > > > > It points to it. (The name...
19
by: MMMMM | last post by:
Hmmm, my array seems to be emptying itself for no reason. I just want to grab every form element posted to the page into an appropriately sized array... What is going on here? dim arrShort()...
1
by: Matt | last post by:
I am trying to create a 2 dimentional array with a uniqId value and another Array.This is the code I am trying but it is not working. Please help me out gurus.. MainArray = new Array(0,0); ...
1
by: Suffrinmick | last post by:
Hello Everyone I've built a database using Access 2000 which includes a query which is built using a form containing filters. No problem. When I export the results of the query to excel, (File >...
3
by: kohvirus | last post by:
Hello everyone. I'm currently trying to write a program with an array but for the life of me I can't seem to get the right syntax for the array. Here is the program as follows: #include...
1
by: Dan | last post by:
Hi guys, I'm trying to automate an excel worksheet through vb.net. So far i've been able to figure everything out. However, i recently ran into a problem. I can ungroup of set of objects with no...
2
by: Ben | last post by:
my program keep crashing itself it executes a structure with static array members such as this: module myModule: ..... structure myStructure ..... <VBFixedArray(8)> dim myArray() As Single...
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
2
by: Edvin | last post by:
Greetings, I'm trying to access C# COM object from a VBscript, where C# will modify the reference parameter to an array. I found simple reference parameter datatypes (i.e. int, string) yield...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.