Checking If Variable Is Multi-dimensional

May 11, 2007

Is there a quick way to check if a variable is an array or multi-dimensional? I am trying to send variables to a sub to print to excel but I am sending mixed variables - some are one dimension, some are two dimensional.

Here is what I am using:


Private Sub Send(Item As Variant, Top As Integer, ToSheet As String, Row As Integer, Column As Integer)

'Sends values to Excel

' Loop counter
Dim i As Integer

For i = 0 To Top - 1
ActiveWorkbook. Sheets(ToSheet). Cells(i + Row, Column).Value = Item(i)
Next

End Sub

I suppose I could set up a second routine to handle one dimensional variables, but I thought I would ask the pros -

View 9 Replies


ADVERTISEMENT

Populating A Multi-dimensional Array

Nov 26, 2008

I have a spreadsheet which I will be adding to over time. I need a macro that will look for the last 10 rows and then pull together a summary table based on data from several of the columns on each of those rows.

I've tried to go about this by using an array. The array will always be the same size (it will always be 10 by 11, i.e. EngineArray(10,11)-basically the same size as my summary table). I've also set Option Base 1.

What I’ve got so far is below. It isn’t working properly though. To start with I was getting ‘type mismatch errors’. Now instead of reading the numbers from the selected cells into the array, it just changes all the cells I’m trying to read from to ‘TRUE’?

View 6 Replies View Related

Summing In A Multi Dimensional Array

May 15, 2007

I've created an array that is 60 pairs of cells wide. Each row in the array represents a different account. The 60 pairs of cells contain up to 60 payments in a payment stream. The first cell of each pair may contain an amount of interest to be paid, or zero if the time band in which it was/will be paid is not within the time range that I'm evaluating. The second cell of each pair may contain a number between 1 and 10 representing the time band in which the interest will be paid, or zero if the payment date falls outside of the time bands.

I need to be able to sum the interest to be paid in each time band for all of the accounts in my database.

Is there an Excel function that I could use or will I need to write some VBA code to loop through each row?

View 9 Replies View Related

Multi-dimensional Array Solution

Jan 12, 2007

I am currently using a macro which highlights keywords and associated page views from an array in my website stats spreadsheet. Now I need to take it to the next level:

I want to use a multi-dimensional array to pull out any keywords that are duplicated, and display them at the top of my spreadsheet with the totaled page views next to them in a different color (red).

Here is my existing Keyword highlighting
Sub Highlight_Keywords()

Dim vntWords As Variant
Dim lngIndex As Long
Dim rngFind As Range
Dim strFirstAddress As String
Dim lngPos As Long

View 9 Replies View Related

Fill Range From Multi-dimensional Array

Jul 20, 2007

I searched and found a few posts about transposing arrays into a range of cells, but none of them seemed to solve my problem. So, my problem is, I have a .Net assembly which provides various functions to allow Excel to access our Oracle DB stored procedures/tables, etc. This assembly is exposed via COM Interop. I call the GetSPINTypes() method, which returns me a list of type pairs (ID, Name), in a CSV string format.

I split the CSV into rows, and then put each row into a 2-dimensional array.
I then need to dump that array into one of my sheets in Excel, so I try to do the usual Range.Value = Array, but this sometimes tells me there is a type mismatch, and most times just doesn't fill the range. I've checked my arrays in the watch window, and they have definitely been filled in correctly, the values just don't appear when they are put into the sheet. See the code I'm using below:......

View 4 Replies View Related

Multi-dimensional Array Not Showing In Listbox

Aug 18, 2007

I have made the function below to return a variant multidimensional array. I pass the function an array of folder paths that I wish to search through looking at subfolders within that path where their name matches a search string that I pass to the function. eg., it will find a folder named "Catnap" if you pass the string searching for as "Cat*".

The size of the array it builds depends on how many folders it finds that match the search string and so needs to be built dynamically. Hence, I believe it builds a 2 dimensional array horizontally and I transpose it at the end of the function. In each element I put the folder name that was found in the first dimension and the path to that folder in its second dimension.

I have a 2 column listbox on a form that I set this array to. eg., Me.ListBox1.List = DirPaths("C:","Cat*",vbDirectory,100)

This works fine and shows a list of folder items found by folder and path in the two columns of the listbox if there is greater than 1 search found. However, when the search only finds 1 then the listbox shows the folder name with the folder path in row 2 of the list box. (See below).....

View 2 Replies View Related

Fill & Rearrange Multi-dimensional Array From Another

Feb 26, 2008

I've got the folowing array's

date1>company1>price
>Company2>price
>company3>price
>enz

Date2>company1>price
>company2>price
>enz

enz.

But these are not the array's that i need for a correlation that i want to make.
Is it possible to transform the array's above to an array such as:

Company>date1>price
>date2>price
>date3>price
>enz

View 5 Replies View Related

Evaluate Multi-Dimensional Array Matrix

Feb 27, 2008

I'm trying to use VBA to do some matrix processing. I have successfully done matrix processing in the spreadsheet, but I'm looking to port the logic into VBA to more easily reuse central formulas and reduce the amount of code in the spreadsheet.

The function shown below works. I had to hack around the variable declarations to eliminate processing/compile errors but it seems to function (no pun intended).

While debugging I noticed that this function would seem to get called 4 times. I do have other modules running, although I don't think any other modules are affecting this.

After some input from shg, I updated the variable declarations, but I'm getting an "Overflow" error reported. Sometimes (not always) a divide by zero also pops up. I do have the Msgbox for errors at the end, I haven't tried removing that part to see if the error reporting vanishes. I'm not sure 'hiding' error alerts is the best thing to do anyway...

View 8 Replies View Related

Join Dynamic Multi-dimensional Array

Apr 15, 2008

the built in "Join" function can join all elements of a 1-dimensional array into a string with delimiter. Now, how do I do that with multi-dimensional array if I just want to join 1 dimension of it.

For instance, I have:

m = 10
n = 20
Redim my(m, n)
'assign values to array here...

'I want to join, say, my(5, 0 to n) only
'How to do that without declaring a new 1 dimension array?

Also, I want to write a join sub/function to do the above for n-dimensional array, do I need to write each one for every number of dimension (1 sub for 2-dimension, 1 sub for 3 dimension, etc.)?

View 4 Replies View Related

Lookup Values From A Multi Dimensional Table / Data Sheet

Oct 24, 2007

I have a sheet that has to look up value on a report from a sheet sheet that has more than value. Ex)
On the report I have values 123A and 1234A
On the data tab I have table that has.

Ref Tot Value Desc Value1 Value2 Value3
1 123A Widgets 1 2 3
2 123A Widgets 4 5 6
Ref Tot Value Desc Value1 Value2 Value3
1 123B Nuts 7 8 9
5 123B Nuts 1 3 5
Ref Tot Value Desc Value1 Value2 Value3
7 1234A Bolts 2 4 6
11 1234A Bolts 3 5 8

So the report need find the values for Value 1, 2, 3 on where the value matches the data tab.

View 14 Replies View Related

Creating A 2-dimensional Array From A 1-dimensional List

Nov 27, 2008

I've been a lurker on this forum for a long while and it's always been able to provide me with lots of excel tips, and for that I am grateful! But this time I have a question that I can't find the answer to here, or anywhere else on the web after a few hours of looking. As a note, I'm not very experienced with Excel, probably somewhere between novice and intermediate.

What I need to create is a 2-dimensional array of data. The vertical (y-axis) are the tools, and the horizontal (x-axis) are the jobs. Where the y-axis and the x-axis intersect, will be the quantity of tools needed for that specific job. There are almost 1500 tools, and 100 jobs.

View 4 Replies View Related

Checking Value Of A Cell Using Variable

Oct 3, 2013

I am trying to check the cells in column C for a defined set of rows and if it is blank change it to astericks.

Current is the row selected when the macro begins
LastRow is the last row with data (in column A)

For i = Current To LastRow
If Range("C" & i).Value = "" Then Range("C" & i).Value = "***"
Next i

View 6 Replies View Related

Multi-Variable Lookup Table

Jun 12, 2014

I make budgets that have line items that have standard price based on 2 factors: a description, and a number. I want to keep these items in 2 different cells. I also have different clients, and the costs are different. I could simplify so that I can use a VLOOKUP with HLOOKUP and separate the clients but I would prefer not to.

Screen shot 2014-06-12 at 12.36.47 PM.png

View 1 Replies View Related

Ranking Spreadsheet (multi Variable Hlookup)

Dec 31, 2008

1. The most amount of wins
2. if two or more people tie the # of wins then the person with the lowest tiebreaker guess wins and the other person becomes the next place.
3. If two people tie the number of wins and the tiebreaker for say 1st place the next highest win and lowest tiebreaker should place 3rd since there are two people above him.

Attached is a spreadsheet of the problem. The solution must only use the info in the "Given" section. You may reorder the data (rows moving up or down, not columns). Solution required is in Yellow.

I could figure out the logic IF there is a way to do a multi conditional hlookup. So if you know of a way to use an "And" in the condition and pull up one row as a result, i can probably figure out the rest.

View 8 Replies View Related

Calculate A Multi-variable Equation Based Off Of Data In A Table With Different Criteria

Jan 8, 2010

I'm trying to calculate a multi-variable equation based off of data in a table with different criteria. If you reference the attached spreadsheet I am trying to calculate cost based on weight and zone. For the data entered in cells B1 and B2 944.01 would be the cost. If you look at the table in G2:N3 you'll notice that the values in G2 and G3 are the weight limits G2 is from 0-4999 and G3 is 5000+, this should impact where the value in B1 falls. B2 should select from H1 to N1.

View 3 Replies View Related

Return Row Index Of Selected Items In Multi Column Multi Select Listbox

Jun 30, 2014

I have a listbox with 8 columns. Multiselect is enabled, and it must stay this way. As part of my program, after the user presses a command button, I need to use the row indexes of the selected rows in order to copy the selected information into an array which is then placed in a different listbox, and then delete the items from the original list. Pseudocode of what I want to do:

[Code] .....

But my understanding is that .ListIndex does not work this way with multiselect listboxes. I've tried searching for a solution for a while, but I cannot find one.

View 5 Replies View Related

1 Column Into Multi-columns And Multi-rows

Jul 16, 2013

Let's say I have one column of;

1
2
3
4
5
6
7
8
9

What is the most efficient way to change this into '3-columns & multi-rows' like this?:

1 2 3
4 5 6
7 8 9

The actual list is a lot longer and numbers are not in order.

View 7 Replies View Related

Concatenate Multi-row Cells Into One Multi-row Cell

Aug 21, 2013

I have multiple rows within a cell separated by Alt+Enter, and would like to combine them as follows:

Desired Result

First
First
Name
Name
First Name
First Name

View 2 Replies View Related

Dimensional Table

Oct 12, 2009

i have a problem with my report.

there is a dimensional table:

DIM RESULTSDIM_111.1DIM_111.8DIM_111.2DIM_25.3DIM_25.5DIM_380.2DIM_380.1DIM_380.35

i need to make a new table in wich all "dim" will repeat only once and the results will be the average of the results that belongs to the same "dim"
the times that the "dim" repeats can change and the "dims" could be not only till 3

View 9 Replies View Related

Macro – Two Dimensional Look Up

Mar 1, 2010

The workbook has two sheets. Sheet1 has numbers in column A going down the sheet and dates in row 2 going across the sheet starting in column B. Sheet2 is similar but the column and rows do not line up with sheet1. I would like the macro to look at the numbers in column A and the dates in row 2 on sheet1 and find the same match of number and date in sheet2 and enter the value from sheet2 into the appropriate cell in sheet1.

I understand it can be done in a formula with index and match but I would prefer a macro.

View 9 Replies View Related

Finding A Value In 2 Dimensional Array?

Jan 15, 2014

i have a sheet in template i use in preparing bid packages for electrical installations.it relates to locating in a (building) grid the locations of the motor control (mcp) and power panels (cdp).my desire at this point is to find a way to local a unique value (mcp or cdp) in a 2d grid and then return the column and row names from the same grid. eventually this information will populate a table of all the mcp's and cdp's with their locations.

my sticking point appears to be finding a unique value in a 2d table. this value can be anywhere in the table, not just the first column.

i've tried the lookups and index/match. match fails when i extend the lookup_array beyond the first column.
not sure if this is even possible.

View 8 Replies View Related

Dimensional Weight Formula

Mar 17, 2009

I have attached a sheet that contains a pretty simple formula that helps me figure out the dimensional weight of a shipment. It is just a simple vlookup that returns the proper rate (Column H) depending on DIM Weight and Zone. It works great.

The issue I'm running into is with various exceptions that I need to put into the formula. The criterias that I need to put into the rate formula (Column H) are:

1-If the one of the Length (Column A), Width (Column B), and Height (Column C) is greater than 60 I need to add 7.50 to the the returned lookup value in Column H.

2-The second longest side the Length (Column A), Width (Column B), and Height (Column C) is greater than 30 I need to add 7.50 to the the returned lookup value in Column H.

3-If the grith (2x Column C + 2x Column B) is greater than 130 I need to add 45 to the the returned lookup value in Column H.

I'm working with a few IF formulas but I can't seem to get all of them to work at the same time. Does anyone have any thoughts?

View 8 Replies View Related

Dimensional Weight Formula II

Mar 18, 2009

calculate dimensional weight (below).

View 3 Replies View Related

Sorting Variants (two Dimensional)

Feb 6, 2014

Is there an easy way to sort variants? I've searched the internet and it seems that sorting works just with ranges

[Code] .....

I have variant M with 20 rows and 4 columns and want to sort the rows according to the fourth row (from the smallest to the largest). I tried analogical things such as:

[Code] ......

which does not work. I do not want to believe that VBA does not have any internal way (function) to solve variants sorting since it should be quite casual thing..

View 8 Replies View Related

Bi-dimensional Dynamic Range

Jun 13, 2006

I've tried the below formula to get a bi-dimensional dynamic range that is defined by the last no blank column and last no blank row, too.

=A1:INDEX(A1:D18,MAX(NOT(ISBLANK($A$1:$D$18))*ROW($A$1:$D$18)),MAX(NOT(ISBLANK($A$1:$D$18))*COLUMN($A$1:$D$18)))

Does any one have a different approach to get this without using the offset function?

View 7 Replies View Related

Interpolate Two-dimensional Array

Feb 14, 2007

With a known X and Y, trying to solve for Z from a table. ie: IF a variable X is defined across a row, another variable Y defined down a column, the data field Z fills in-between. What do I need to use to interpolate for both X and Y to solve for Z?

View 9 Replies View Related

Function For 2-dimensional Array

Feb 27, 2007

I am trying to write a public function that fills a table for a 2-dimensional array and am having trouble with my named ranges. The x-axis is based on years (range F2:O2) and the y-axis is a q_factor (range E3:E23) so the data range would be (F3:O23. The following outlines my logic:

Public Function bondValue(years As Range, q_factor As Range, z As Double)

Dim nRow As Long, nCol As Long
Dim bondPort As Range

nRow = q_factor.Rows.Count
nCol = years.Columns.Count
sumTau = 0

View 6 Replies View Related

Double Lookup From Two Dimensional Table

Apr 2, 2009

I am trying to get a cell in my spreadsheet to look up a value based on two values. I have a dropdown list that lists the worksheets in the workbook, and each worksheet has a table with width measurements for the columns and height measurements for the rows. I have a function that is mostly working, it calls the data from the proper worksheet, but it rounds the measurement values down, and I need it to round to the next highest value on the table.

For instance, the measurement may be 55" x 55" in, but the table has values for 54" and 60". The current formula rounds down to the 54" measurement, but I need it to round up to the 60". I have attached what I have so far with further notes and cells highlighted.

View 4 Replies View Related

Filling All Elements Of A Two Dimensional Array?

Dec 3, 2009

Filling all elements of a two dimensional array?. I know that I could write something like:

View 3 Replies View Related

Distinct Values From 2-dimensional Range?

Sep 18, 2012

I'm a huge fan of the DistinctValues function published by C Pearson here: Distinct Values Function

Now I have the problem that I need to get all the distinct values from a 2-dimensional range.

View 1 Replies View Related







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