In order to be able to replicate something like the MATCH function, which accepts a String (or cell reference), an Array of Strings (or a range of cells) and then the match type as parameters, how do I declare such a function header?
it is returning #VALUE without executing any of the function. It is something to do with the Array of Strings that is causing the problem.
I am trying to loop through the values of an array that was populated from a range. Essentially I'm trying to manipulate a pivottable depending upon what a person selected in a control form. Below is my Dim userWeekArray As Variant userWeekArray = Sheets("Valid Values").Range("A20:A27") For w = 1 To 8 If .PivotItems(w).Name = userWeekArray(w) Then .PivotItems(w).Visible = True Else .PivotItems(w).Visible = False End If Next
I get an error message stating that Subscript is Out of Range. It seems Excel is assuming that userWeekArray is a Range object when I want it to be an Array. How can I populate an array with elements from a range in a worksheet so that I can then easily loop through the array to examine the elements?
I want to have a dynamic range that will increment and return a value to a variant for some comparisons. Here is what i have
For i = 0 To 50 If [Q + i].Value <> "valid" Then Goto GotLicenses Else varHostNumber(i) = [C + i].Value MsgBox varHostNumber(i), vbOKOnly End If GotLicenses: Next i
I want my if statment to use the variable "i" as part of the range for the comparison. Right now the msgbox is just to see what is happening, but will later become a different if statment that will blank a cell's value if it doesn't match the array variables.
A B C D -------------------- Mike Fax 5 60 John Tel 3 30 Mike Tel 2 30 Mike Fax 1 60 John Fax 1 60
-------------------- hi all, i am faced with the following problem. before i describe the problem, i do not need help with recording a macro or using functions to solve the above problem, i know how to do that.
writing a code from scratch to do the following:
I need a code that will run through the above columns, and IF A=Mike and B=Fax, THEN C*D...so I want to calculate a total for everytime Mike sells a Fax (or a Tel). Column C is quantity, Column D is price.
I am sure this is a simple loop code, but I have spent days trying to figure it out and I can not do it. Recording a macro is useless, because it is too confusing to look at the code and play with it and try to personalize it.
I am trying to apply conditional formatting to the range K60:R82 based on their corresponding cell in the range K87:R109 (the arrays have the same size). If each cell in the first range is greater than their corresponding cell in the 2nd range, then the cell in the first range should be formatted with pink fill and red text.
I have created a 3d array in visual basic that i want to access from a worksheet. it is basically a linked set of 2 dimensional arrays (i.e. there a x items with a x b data arrays). I want to stored in a named range, as a and b may both be more than 255 (i.e the width of a worksheet). is there an easy way to store and reference a 3d array in a name, or will i have to store each a x b array as a seperate name. Also, if I have to store them separately, is there an easy way to strip the component parts of a 3d array into 2d arrays?
I need to rank the top 3 names for each location based on gender (see sample data table below).
My spreadhseet has been setup using dynamic named ranges ("Size", "Name", "Gender", "Location" and "Score") using the formula "Size"=MATCH("zzzzz",'Sheet1'!$A:$A) and then "Name" =OFFSET('Sheet1'!$A$2,0,0,Size), and so on for "Gender", "Location" and "Score".
Is there a way to design an array rank formula using the dynamic named ranges to return the name associated with the highest score for "M"s in location "N"? I want to be able to edit the formula so I can chose which rank to display (e.g. 3rd, 7th, etc).
I've been playing with the following but can't get it to work
I am retrieving a CSV file from the net. In this file there are 'x' amount of row data and 7 columns. I only care about the values in the 7th column for each row. I also don't care about the entire first row. A graphical version would be represented something like this, with the values I want colored in orange:
I've managed to dice this thing into a jagged array by first splitting it using vbLf as a delimiter, and therefore adding those to an array called Lines(). Then I split Lines() up using commas as the delimiter and threw those into a jagged array, let's call it Breadcrumbs()(). I want to throw all the values from Breadcrumbs(i)(6) into an array of its own. Here's my code so far:
Code: Public Sub CSVparser(file As String) Dim Lines As Variant Dim j As Integer Lines = Split(file, vbLf) ReDim breadCrumbs(UBound(Lines)) As Variant For i = 1 to UBound(Lines) - 1 breadCrumbs(i) = Split(Lines(i), ",") Next i End Sub
Is it possible to set parameters on a query but use a wildcard to return all instances? I have a query that I want to be able to set multiple parameters on but give the user the ability to select as many or as few parameters as they want to see. 2 of the parameters are number fields and 2 are text fields with no spaces.
I am trying to add a 0 if it is missing at the start of the number in columns K2:K3000 and L2:L3000, The numbers do not have fixed lengths so I cant use the custom setting but if the number starts with a 7, 8 or 3 I want to add a 0
I need to have a code that looks up Column 1 (Parameter 1) first, then looks up Column 2 (Parameter 2), and inputs Column 3 (Value). The code needs to be in a SINGLE cel.
I thought initially using a Lookup function within another Lookup function might work, but I can't seem to get the code to work properly.
I'm working on an attendance tracker for church. We will have folks scan a QR code and fill out a 2 question survey: Name of person being checked in and date of check in. Both are mandatory and are set in such a way as to always have the same formatting every time. That's my first sheet, it just gathers the data. My second sheet actually has the attendance tracker with the roll and dated columns. What I'm trying to create on the second sheet is a formula that will search the first sheet for the date and name and return a 1 if they were there that day.
I have a query that has criteria based on "is one of". I would like to pass this off to a parameter selected from a list box where the user could select multiple items. Is something like this possible?
I have a spreadsheet in which one column I'm trying to find a value in another table that has 3 columns (A, B, C). I need to find all the values in A, that fulfill the parameters of less than 1.5 in B, and great than 5% in C.
They all need to be listed in column H while skipping the records that do not meet this criteria.
So below is an Sample (Actually about 200 people) of a manually finished product (without names). All parameters must be met.
Basically it will break the Big groups into smaller groups of 4. Assigning the smaller groups a numeric group number starting with 1.
Parameters. No more than 2 members of a club in one small group. No more than 7 lbs between lowest weight member and largest weight member. If it can not complete this, a 3 or 5 (preferably 5) man group can be made.
I am getting erors when i am trying to use excel parameters in sub query
select gen_fundnumber from FilteredGen_fundmain where gen_customeridnumber = (select distinct gen_customeridnumber from FilteredGen_fundmain where gen_fundnumber =? )
If I am changing the ? to '123' it works fine.. The second select with the ? parameter is running alone excellent.
How can I get at parameters passed on a command line to Excel 2007?
For example invoking Excel from Vista's Run command with: "C:ProgramDataMicrosoftWindowsStart MenuProgramsMicrosoft OfficeMicrosoft Office Excel 2007" "C:GZNORPWeather StationParamTest1.xlsm" /e/abc/def
Should reveal the parameters "abc" and "def". But this does not happen!
Supposedly, the API function GetCommandLine does this, but I cannot seem to get it to work. Here's a sample of what I've been trying:
I've got some data formatted by column in the worksheet that I'd like to pass into the function and have it return something from an array. This is essentially a replacement for vlookup, but easier considering the volumn of data I've got. Take something like this...
Column N will have integers (0 through 20)
I want to pass contiguous parts of N into the function and have it return the corresponding sum of values from the respective positions in an array I defined locally. Here is the function:
I have a long list of past jobs, around 4000+. I have multiple fields, but I really wish to concentrate on the:
1) Job Type - Example would be Medical or Imprint
2) Job # - Correlates when it was done - Example would be 91059 would be a job within 2008-2009 fiscal year.
All the jobs are listed in the first spreadsheet. The second spreadsheet will hold generalized data broken down by the Type of Job and the fiscal year it was done.
I wish to first count how many jobs fit a specific job type. This was easily done:
=COUNTIF(Data!A2:A4121,A7)
A7 = Medical A1:A4121 = the range of the names.
Count comes up as 346, which is correct.
I then want to add another parameter to break up the 346 by fiscal year. It ranges from 05-06 to 08-09. I came up with this:
Since the job # correlates to the fiscal year it was created, anything starting with 9 is a job done in 08-09. Anything starting with an 8 would be of course 07-08 range. I would have multiple fields with each different fiscal year.
However, when I put the 2nd formula in the function didn't work. It keeps the count at 346, which I know is wrong. I am not sure if I did something wrong here. Been looking at this for an hour and can't figure out what is wrong. The jobs that are medical within 08-09 fiscal year should be 120, but it keeps at 346.
Im currently using the below formula but was wondering if its possible to combine the parameteres that im looking up in coulmn L in sheet one so i dont have to do the formula three times? something along the lines of={"P11111";"P22222";"P33333"}?
I am trying to write an SQL query using parameters in an Excel Worksheet and then return the results to the current sheet ar cell B11. I have found it imposible to make it work in SQL so am trying to run it from VBA to pass the parameters. These are named cells StartDate and EndDate in cells A2 & A3 respectively and should replace the constant dates below. I am working in Excel2003 & MS SQL 2012.
I have tested the query on SQL server with fixed values (which are still in it). It works fine & I have pasted it in.
I took an existing query I found & tried to modify it for Excel2003 but ... Whatever syntax I use, I get a Run-time error 424 when I get to a line with 'connection'
Code:
Sub DateQuery() With ActiveWorksheet.connections("ndserver01").oledbconnection ' .Connection = "OLEDB; DSN=Excel Files; provider=SQLOLEDB; Catalog=NDM_Sage200;Data Source=ndserver01" .Refresh BackgroundQuery:=True .CommandType = xlCmdSql
I have some code that works fine below. It deletes an entire row based on the value in column J.
Ideally I would like to give the user the option to choose which column to base the deletion on. i.e. some kind of drop down box or input parameter where they could choose a different column "A", "B", "C" etc...
Private Sub CommandButton1_Click() 'Removes values less than 0 Dim rng As Range, cell As Range, del As Range Set rng = Intersect(Range("J1:J1000"), ActiveSheet.UsedRange) For Each cell In rng If (cell.Value)
I have a range of data in columns a-g (the length of which i am unsure of). I have been manually sorting them for the values in both column a and column g, but the data in column b-f are needed for my work. would it be possible in one sheet to have column a "y" and on another column a "N" sorted and then subsequently, the numbers in column g copied and pasted along in rows after so you would have a-g copied in h-n and then for the next number o-u and so on. there are multiple of the same value in column g, and a. would it be possible to make a macro which would sort this for me
I'm trying to figure out how to pass parameters to a date field in a macro to control the display in a pivot table. The macro currently uses a With statement to set the properties of 177 of the 180 dates to false, leaving the remaining three dates true and visible.
I have a workbook that requires a multiple of 3 to be entered in a cell. If a quantity other than a multiple of 3 is entered, a Msgbox pops up and requires the quantity to be changed to such value.
I am looking for where this is handled. I found part of it in a Private Sub:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub But I cannot locate where the other parts of the code is stored.... I would like to see how this is handled so I can incoporate this in my own worksheets.