Cycling Through 1 Dimension Of An Array

Aug 17, 2009

Using index, I know passing 0 as the row or column num returns the entire row or column.

So I have an array containing worksheets, and an associated column number:

View 3 Replies


ADVERTISEMENT

Is Two Dimension Array Empty

Feb 21, 2007

I'm trying to write a function that I can pass an array along with the data I want added to that array. The function will resize the array, put the data into it and return the new array. Example:

Function AddNewDataToArray(MyArray As Variant, Arg1 As String, Arg2 As String, Arg3 As String) As Variant
'If no elements have been added
Redim Preserve MyArray(1 To 3, 1 To 1)
'Add the first record of data to the array.

'If there is already data in the array
Redim Preserve MyArray(1 To 3, 1 To UBound(MyArray, 2))
'Add the next record of data to the array
End Function

As 2 dimensional arrays are Base 1, the challenge I have is getting it to resize (redim preserve) the array when it has to add the first record. I thought I could just use an IsArray function to test if there had been any data added. If not, then it would run the following...........

View 3 Replies View Related

Redim - Re-dimension An Array

Nov 16, 2007

Currently I am building a class to keep track of entries I have made during the macro execution. Thus far I have:

Private Type Memory
MemoryArray() As Variant
End Type

Private Sub Class_Initialize()
Redim MemoryArray(0) As Variant
End Sub
Public Property Let AddToMemory(Object As Variant)
'memory is empty
If UBound(MemoryArray) = 0 And MemoryArray(UBound(MemoryArray)) = "" Then
MemoryArray(0) = Object ..............

View 5 Replies View Related

One Dimension Array From 1 Column Range

Oct 9, 2007

I am trying to write a function that grabs the value of some cells in a column and returns a String array with those values. I am getting a compiler error on the line where I assign a value to an array element. It appears to be assuming that rather than an array reference, I am trying to do a recursive call to the function. The error is "Function call on left-hand side of the assignment must return Object or Variant." I would have done this with by assigning the range directly to the array but the data is in a column rather than a row; don't know of a more elegant way to do it.

Public Function projectList() As String()
Dim c As Range
Dim i As Long
For Each c In Range("FirstProject"). CurrentRegion
Redim Preserve projectList(UBound(projectList) + 1)
i = UBound(projectList)
projectList(i) = c.Value ' *** Compiler error occurs here ***
Next c
End Function

View 3 Replies View Related

Passing An Entire Dimension Of An Array To A Function ..

Jul 9, 2009

Passing an entire dimension of an array to a function....

View 13 Replies View Related

Program Multiple Elements Of Multi Dimension Array Simultaneously

Aug 23, 2012

Is there any way to do this part of code without calling out each element individually?:

VB:
Dim aSequence(7, 1) As Integer
'setup Evaluation sequence
aSequence(0, 0) = -1

[Code]......

View 2 Replies View Related

Cycling Through 2 Arrays

Jan 24, 2012

I have an array that will open specific workbooks. But Now I need to append a Case Number to the beginning of the file, and I don't know how to cycle through two Arrays. I have been setting it up as:

Code:
Dim Report
Dim Reports
Dim WB AS Workbook
Dim WS AS Worksheet

Reports = Array("Case01", "Case02", "Case03", "Case04")

For Each Report in Reports
Then I open the workbooks and print them.
Next Report

Now I want to add in a 2nd Array, that will Append the 1st item in CRN to Reports, then the 2nd item in CRN to 2nd item in Reports. So it would look something like this.

Code:
Dim Report
Dim Reports
Dim CRN
Dim CRNS
Dim WB AS Workbook
Dim WS AS Worksheet

CRNS = Array("0501202201", "0134851081", "9715288103", "1697774009")
Reports = Array("Case01", "Case02", "Case03", "Case04")

For each CRN in CRNS
For Each Report in Reports

Then I open the workbooks and print them.

Next Report
Next CRN

But that cycled through each CRN before moving to the next Report?

View 9 Replies View Related

Cycling Through Worksheets

Jan 21, 2008

I have 7 worksheets, each worksheet has a range of data, in the first instance 10 numbers in cells A1:A10.

I'd like to copy this range and paste it into another worksheet within my workbook.

Is there a way to do this, possibly using Dim WS as Worksheet and then using a For Loop?

Another problem I have is the necessity to paste the data from a columnar format into a row format, ie A1 stays as A1, but A2 would become B1 and so on..

View 9 Replies View Related

Cycling Through Files In A Folder

Sep 21, 2009

I'm a novice with VB, so go easy on me. I'm trying to write a macro to copy the same couple of cells from hundreds of excel files and paste them into one summary file. What I've written so far is:

View 10 Replies View Related

Date Not Cycling With Addition Of Time

Oct 26, 2011

Adding date and time. The code is listed below.

I have watched the code while running. The initial date FDateS and FDate(t) value is m/dd/yyyy (9/16/2010) and no time. FDateS has different amounts of time added to it. The issue I have encountered is that once it passes midnight, the date does not change but the time reflects the change to 00:00:00.

Public FDate(1000) As Date
Public FTime(1000) As Date
FDate(t) = CDate(Mid(FindData("sm_Sys_BatchOpenTime"), 1, 10))

For H1 = 1 To n
FDateS = FDate(H1)
For r =1 to 50
FDateS = CDate(FDateS) + CDate(FTime(r)-Ftime(r-1))
Next
Next

View 1 Replies View Related

Cycling Through Two Ranges To Complete Blank Data

Nov 23, 2011

Any way to cycle through two ranges and fill in blank cells. The worksheet has a "header"(A2:H2) that bascially determines how the rest of the sheet will be filled out. This header is subject to change if one of the headers is changes(see PLAN, and TRAN CODE in example).

PLANSSNDATEFUNDSRCTRAN CODEITEM CODEAMOUNT (CASH)56016999-99-9999FBLNK01699161.00022.00033.0060988999-99-9999fBLNK0150595.00026.00037.00

The SRC and AMOUNT(CASH) fields will always be complete. What I'm trying to do is cycle through AMOUNT(CASH) and if the field is not blank to then cycle through crng lookig for blank cells. If the cell is blank it should copy the cell above. This is where I'm headed but it will cycle through the same crng(A3:H3) every time.

Public sub Line_Check
Dim ccell As Excel.Range
Dim crng As Excel.Range
Dim hrng As Excel.Range
Dim hcell As Excel.Range

'skip A1, A2(add code to validate headers)

[Code] ........

View 5 Replies View Related

How To Make Box With Dimension

Oct 26, 2011

I just need to know that is it possible in excel that we could make box with length, width, height dimensions?

For example: we just enter 100mm is length, 70mm is width and 30mm is height.. so excel will make box according to this size

View 3 Replies View Related

Print Area Dimension

Feb 26, 2010

I used the macro recorder for this:

ActiveSheet.PageSetup.PrintArea = "$A$1:$P$246"

How would I change this to use variables?

I need to set the print area to A( FR ) to P( LR )

Of course FR is first row, LR is last row

View 9 Replies View Related

Pull Out Daily Staff Location Schedules From A 20wk Cycling Rota

May 18, 2006

I need to pull out daily staff location schedules from a 20wk cycling rota. and produce daily shedules for staff and more detailed for the wolves above.
Attached file gives an idea of what I am trying to achieve.

View 8 Replies View Related

The Specified Dimension Is Not Valid For The Current Chart Type

Feb 19, 2010

when opening the workbook with Excel 2010 beta I folllowing error:

Run-tim error '1004':

The specified dimension is not valid for the current chart type.

View 9 Replies View Related

Multiple Dimension Crosstab Convert To Flat File

Oct 6, 2012

VB:
Sub CreateFlat()
Dim wsData As Worksheet
Dim wsNew As Worksheet

[Code].....

In 2006 posting, this code was presented to the Forum. It works perfectly for a one dimension Crosstab. I have 4 dimensions that I need copied to the output.

I have attempted to modify the code, but nothing appears to adjust the pull of more than the first column of dimension data.

see the attached spreadsheet for the Crosstab data and desired output.

View 8 Replies View Related

Treating String As Array And Correct Array Format For Unicode Characters?

Jul 30, 2012

in C a string is nothing more than an Array of characters ending with a null character.

in VBA this does not seem to be the case.I am trying to use the BlowFish code from David Midkiff for some encryption, however the code sometimes fails:

When encrypting a string a string of a specific length should be returned. however sometimes one of the characters of the encrypted string is a null character, and the returned encrypted string (with a embedded null character) is causing me problems. I want to check for the null character and if present redo the encryption. But how do I check for the presence of this null character in a unicode (double-byte) string?

Checking with Len(encrypted) gives the correct length (!) but trying to move each (unicode)character into an array fails when using the Mid() function past the null character in the string.

Now I can use

byteArray() = StrConv(unicodetext,vbFromUnicode)

to get the lower byte of each character into an array easily, but how do I do this for both bytes of the unicode characters?

Using an integer array does not work other than through

intArray(j) = CInt(AscW(Mid(Outp, j, 1)))

which fails on the nullstring in my encrypted text.

I have tried with variants but so far no luck. I thought if the string was entered into a variant then I could also address the variant as an array of bytes, but that does not seem to be accepted by VBA.

View 1 Replies View Related

Populate Multiple Array Variables With Same Code By Dynamically Changing Array Name

Sep 9, 2012

I am trying to populate many arrays with the same code using something like this. For this test, assume the following data in A1.

1
2
3
4
5

6
7
8
9
10

11
12
13
14
15

16
17
18
19
20

21
22
23
24
25

Code:
Sub populate()
Dim firstArr(5), secondArr(5), thirdArr(5), fourthArr(5), fifthArr(5) As Integer
Dim r, c, num As Integer

[Code]....

The above code does not work of course and falls over. I am unsure whether I should try and concatenate with something like this eg "" & arrName(i) = Cells (r,c) or go down a different route.

View 6 Replies View Related

Search Substring Of Array Matching List Of String From Another Array?

Dec 20, 2013

I need to export this to Xcelsius which doesn't support any macros/vba. Btw I can;'t use Row() in xcelsius too.

[Code].....

View 4 Replies View Related

String Array Values To Array Of User-Defined Types

Oct 2, 2008

I have a class module with several private variables, including one that is an array of a user-defined type. I am trying to set the values of a single element of this array with "Property Let ..." from a string array:

View 4 Replies View Related

Converting 3x10 Array To A 1X30 Array To Run A Match Formula

Apr 7, 2009

Say I have 3 columns of data: A1:C10 and I want to run a Match() function on them all together to see if I get a match any one those cells, say the value of have in X1.

Since, Match only allows a One-Column lookup array.. is there a way to "concatenate" or "append" the 3 columns together within a formula so now I would be looking to Match in an array that is 1 column * 30 rows?

Basically want to convert =Match(X1,A1:C10,0) to =Match(X1,A1:A30,0) without moving around the raw data in the sheet.

And I want to avoid doing an AND or OR formula that uses 3 separate MATCH() for each column.

I have a hunch that the MMULT or MMULT/TRANSPOSE functions are involved, but can't seem to get it right.

View 6 Replies View Related

VBA To Output From Array Based On Variable In One Element Of Array

May 2, 2013

I'm only starting to get to grips with arrays. I have what I consider to be a lot of data that I need to 'cut' into separate workbooks. I have written some code that does this by simply looping through each line, 250k+, checking against a variable and copying the row into a separate sheet. This took longer than it would have doing it manually. It was suggested to me that I use arrays to speed up the process. I have managed to store the test data into an array but am struggling to find a way to loop through and pull out an entire 'row' from the array based on a variable. I have looked for 2 days in various places to find some way to loop through the data held in the array, but to no avail.

That code will appear here from about 8am GMT tomorrow. I know that once I've cracked this I'm on the road to some very significant time saving and comprehensive report writing.

View 9 Replies View Related

Passing Array To OFFSET - Array Height Parameter

Aug 5, 2014

I want to pass an array to Offset in the "Height" parameter, without having to type the array.

{=MAX(SUBTOTAL(9,(OFFSET(A1,ROW(1:5),,{1,2,3,4,5}))))}

I can't seem to figure out how to build the {1,2,3,4,5}. I've tried another ROW(1:5) and have tried nesting that like N(ROW(1:5)) but nothing works.

How I can get the {1,2,3,4,5} without having to type it out (so that I can expand this to a larger list)??

View 8 Replies View Related

Filter An Array (the Longer One) Using The Shorter Array As The Criteria

Aug 26, 2009

I am trying to filter an array (the longer one) using the shorter array as the criteria. I am currently doing this using the following method

IF(LOOKUP(lookup cell, array)=lookupcell, lookupcell, "FALSE")

I then copy and paste 'values' and filter out the 'false' to get my final result.

This has worked in the past, but for some reason that I simply can't figure out, the formula isnt working! I've attached the example, and I've highlighted a number in blue (cell E522 and C103), (that should be being found in the 'LOOKUP' function) but is returning a "FALSE". I have looked over the code and simply can't figure out why Excel isn't returning the right value.

This is obviously happening for a quite a few of my numbers, as my filter result is returning an array that is about 1500 shorter than it should be. I have highlighted E522 as the 'example cell' to look at.

View 6 Replies View Related

Convert Boolean Array To Integer Array?

Jun 21, 2014

wondering is there a VBA equivalent of --() in excel that turns trues and falses to 1's and 0's?

View 14 Replies View Related

Index Match Array New Formula Not Array?

Nov 6, 2013

Is there anyway to recreate this formula w/o it being an array ?

{=IF(C3="","",IFERROR(INDEX('Master List'!$B$1:$B$2000,MATCH(TRUE,ISNUMBER(SEARCH('Master List'!$A$1:$A$2000,C3)),0)),"ADD TO MASTER"))}

View 5 Replies View Related

First Array Remain Same,second Array Always 11 Cell Added

Nov 15, 2007

=CORREL(C1:C10,C12:C21) at H1
=CORREL(C1:C10,C23:C32) at H2
=CORREL(C1:C10,C34:C43) at H3
etc

can i have a macro that first array remain the same, and second array always 11 cells added. drag it down also can

View 9 Replies View Related

Multiply Each Element In A 6x6 Array By A Similar 6x6 Array

Mar 22, 2007

I've tried to multiply each element in a 6x6 array by a similar 6x6 array, both on the same sheet, and it worked.(see Macro2 and attached xls file "Test").Then I got more ambitious and tried to do the multiplication from a standard array in sheet "TestA", with the result on the same sheet, by each array in sheet "TestB" and failed.How do I solve this problem? Pgualb PS:I'm using the R1C1 style.

Sub Macro2()
For y = 29 To 34
For x = 2 To 7
Cells(x, y) = Cells(x, y - 27) * Cells(x, y - 18)
Next x
Next y
End Sub
Sub Teste12()
'Multiplica matriz em TestB por matriz padrão em TestA com _
'resultado na matriz em TestA correspondente à matriz em TestB
'
Dim x, y As Integer
For y = 2 To 7.............

View 7 Replies View Related

Array Find Or Array Search

Aug 15, 2014

Assume that I have in Sheet2 a list of CUSTOMIZED name.

[Code].....

Now in Sheet1, I have data in column A that has strings consist of the customized name.

For example

[Code] .....

What function should I use that could give me the result of the CUSTOMIZED name?

I was thinking of a formula i.e.

[Code] ......

Obviously, the above formula give me error. Even if it works, it'll not give me the customized name ...

View 3 Replies View Related

Creating Array From 2-dimensional Array

Nov 28, 2011

I'm new to arrays. They seem promising for what I want to do though...

Heres where I'm at. I have some data like this:

items freq 1 0.5 2 0.5 3 0.5 4 0.25 5 0.25 6 0.125

Now, I've created a 2 dimensional array, as such:

Code:
Sub testarray()
Dim arr1 As Variant
Dim rng1 As Range
Dim lngX As Long

Set rng1 = [A2:A6]
ReDim arr1(1 To rng1.Count, 1 To 2)
For lngX = 1 To rng1.Count
arr1(lngX, 1) = rng1.Cells(lngX, 1)
arr1(lngX, 2) = rng1.Cells(lngX, 2)
Next
End Sub

Now, what I need to do, is create an array for each freq of all the items that share that freq. Essentially I need this:

0.5 {1,2,3} 0.25 {4,5} 0.125 {6}

Now, I was thinking, if I could create a dictionary object and make the key the freq (so my keys would be 0.5,0.25,0.125) then I could assing the "item" an array (or another dictionary) holding the items that apply to that freq.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved