Lookup Nth Occurrence Or Instance
I have a very very long weekly table of, say, sales regions, items sold, revenue, profitability, etc.
(Very long here means 120,000 rows, and in Excel 2007 - please don't hold this against me! )
Let's assume Row 1 and Column A are for headers. So Column B is Sales Region and Column C is Item Name. The first Sales Region, beginning in B2, let's call it "America", will repeat (B3, B4....) until the Item Names are done for that region. Then the next Region starts, "Australia", and the list of Items starts again, etc.
Not all the Items will be sold in every Region each week, and even some Regions may disappear from the table one week only to reappear a few weeks down the road. The table is Sorted alphabetically, though, first by Region, then by Item.
One way to VLOOKUP week over week information from last week's report onto this week's report is to concatenate both weeks' Region and Item information (=B2&C2) seperately, and VLOOKUP by that. This returns only combinations of Region/Item that occured in the current week, and with ISERROR, 0 for combinations that occured this week, but not last week. As far as what it returns, this is fine for our purposes but with several pieces of information to VLOOKUP (#, revenue, profit, etc.) and 120,000 rows, it takes forever. Literally over an hour to copy down the week over week parts.
I had the idea that maybe it would be faster if I could define individual VLOOKUP ranges for each Region, and then look up Item within that range. These ranges would vary in placement in the table and in numbers of rows each week, as the number of Items sold in each Region waxes and wanes, hence "dynamic ranges" - I hope I've used that term correctly.
Is there an effective, efficient way to return the row numbers of the first and last instances of a given Region, and use that range for the Item VLOOKUP?
View Complete Thread with Replies
Related Forum Messages:
Lookup Each Instance Of Repeated Data
In the sample file attached, I want to do a lookup with the employee id in the master sheet and find the multiple results in the "open_text" sheet. From there, I want to display the open text results in one row per employee on the master sheet. If there are multiple comments, then the results will be displayed in separate cells to the right of each other (filling comment1 through comment5 if needed).
My main goal at the end of this is to be able to do a mail merge out of the master file. This is why I want the results in one row per employee.
Lookup Second Occurrence With Vlookup
I am using vlookup to find the ORIGIN data and DESTINATION data but the subheading is the same for both- see below(site name, city...). How do I find the second occurrence for the same heading?
Is there another command that would be better?
col A col B
Line#1 CONTACT NM
Line#1 CONTACT PH#
Line#1 CONTACT EML
Line#1 SITE NAME
Line#1 ST ZIP CTY
Line#1 CONTACT NM
Line#1 CONTACT PH#
Line#1 CONTACT EML
Line#1 SITE NAME
Line#1 ST ZIP CTY
Return Nth Lookup Occurrence
Is there a way to build a formula that looks up the first record in a table that has a value of A and X? Value =A Value=X. The next formula would would then return the next record that was a value of A with a value of x that was greater than or equal to 4?
1 A x
3 A x
5 A x
The 1st formula would return a value of 1.
The 2nd formula would return a value of 5.
Return Occurrence Number Of Lookup
I've found Nth_Occurrence and it's frankly brilliant but I need to be able to return the occurrence number of a value in a range and it doesn't quite do what I need.
Using = COUNTIF(A$1:A1,A1) gives me exactly the answer I need but as I'm working with big ranges it's taking a lot of calculation time.
Lookup Nth Occurrence Of Date & Return Adjacent Cell
I have a list of dates in column AF. I would like to retrieve a value from the 2nd occurrence of a date, so I used the function for the Nth Occurrence on this website as follows:
Function Nth_Occurrence(range_look As Range, find_it As String, _
occurrence As Long, offset_row As Long, offset_col As Long)
Dim lCount As Long
Dim rFound As Range
Set rFound = range_look.Cells(1, 1)
For lCount = 1 To occurrence
Set rFound = range_look. Find(find_it, rFound, xlValues, xlWhole)
Nth_Occurrence = rFound.Offset(offset_row, offset_col)
The excel formula I am using is as follows: =Nth_Occurrence(AF2:AF622,AE2,2,0,1)
Where AE2 is the date I am looking up. My question is this: When I put in a date ("1/12/2007") instead of AE2, i get the correct value. I tried giving AE2 and the AF column the same date formatting (3/14/2001), but this doesn't work. The date I am searching for also changes, so I cannot just type the date into the excel formula.
Add 2 Instance >=.01 Of First Instance Of >=.01
I have the following
Private Sub test2()
Dim c As Range, t As Long
Set c = Range("AO10", cells(Rows.Count, "AO").End(xlUp))
t = Application.WorksheetFunction.Max((Application.WorksheetFunction. CountIf(c, ">=.01") * 2), 0)
Sheets("Template").Range("D3").value = t
'Range("D3") = t
The code is suppose to get the value of >= 1 percent from AO10 then go down the column until it finds the second instance and then add that number to the tile.
Thanks for any help in advance.
Have a great Friday all! : D
Close Instance Through VBS
how to close the instance of excel created by my VBS script.
I run the script to open a workbook run a macro within the workbook and save it. I'd like to also close the workbook and the instance of excel.
If I close the workbook within the end of my macro I get an unknown run time error from my script. If I elect to just save the file and close it within the end of script, the workbook closes but the instance of EXCEL.EXE is still running in task manager.
VLOOKUP - Last Instance
Using Excel 2003 SP2. The formula =vlookup("apple",table,2,false) would return the data in the second column of the array named "table" for the FIRST INSTANCE it comes across for the word "apple." Is there a formula to have it return data for the LAST INSTANCE? This is one where I say to myself "Self, there has got to be a way to do this," but I just can't figure out what it might be.
First Instance Of A Value In A Column
I need a simple formula which does the following: I have a column of numbers, and I want to find the first instance which is equal or greater than a specific number. For example,
If the specific value is 55 the formula needs to return: 67
if the specific value is 10 the formula needs to return: 23
Returning First Instance Of Zero
I am trying to create a formula that will search a row left to right for the first instance of zero and return the corresponding column label. I had this working for a smaller table using a couple of hidden columns with nested ifs however the new data set is approximately 25 columns wide and it will get very messy using the same approach. See attached sample with desired results.
Multiple Instance Of Excel
I am working on an application for a monthly sports tournament that I run. There are three workbooks to this application: the Administration workbook, the Bracket workbook, and the Leaderboard workbook. I currently have a dual monitor setup (extended, not clone) with my laptop in front of me and a large TV on the wall for the players to see.
In order for the players to see the bracket and the leaderboard, I open excel, then I open the Bracket.xlsm workbook, then the Leaderboard.xlsm workbook, and I drag those to the TV. I then open another instance of excel on my laptop, and open the Administration workbook. This stays on my laptop and the players cannot see it.
Here's what I want it to do:
In less words, the administration workbook controls the other two workbooks. Every time a player reports a win/loss, I enter that into the Administration workbook, and that needs to update both the bracket and the leaderboard, so the players can see it on the TV. So, basically, all the data is in the administration workbook, and the other two serve as displays for that data in a format the players can understand.
Here's my problem:
When I run a macro that is supposed to update the other two workbooks, I get an error: "Runtime Error '9': Subscript out of range." I believe this is because of the seperate instances of Excel. Since Bracket and Leaderboard are in a different instance than Administration, it can't 'see' those other two workbooks. Below is the part of the code that deals with these three workbooks: ....
Find Last Instance In A Column
I am in the process of designing an inventory like spreadsheet with prices. If possible, I'm trying to find a well to look at a column for every instance an item shows up (lets call them apples) & then find the LAST instance of apples showing up to pull the pricing of that row only. Is this possible?
2d VLookup: Unique For Each Instance
Column A contains numbers that repeat themselves. in column B codes are assigned to each number. numbers in column A may have multiple codes in column B. but are unique for each instance the same number may appear in column A.
what i'm trying to do is.
have the numbers in column A show only once and then have the codes for the corresponding codes appear each in seperate columns rather than all in one.
Last Occurrence From Many
I am trying to extract the last occurence of ppp (4th column). So as long as 4th column is "ppp", i would want to extract the row wher the the last "ppp" occurence start and display in sheet2 "108-Jan-07vcdppp4". If data in 4th column is detected to be "ppp1", it would also extract the row wher the last "ppp1" occurence start and display in sheet2.
Note that the number of ocurrence is random and do not follow specific pattern. Pls see the attached for the example.
Last Occurrence Of A Particular Value
I would like to lookup the last occurence of a particular cell value in a worksheet and use the cell value in the column immediately adjacent to this one in a calculation.
For example, The text "Run #" occurs several times in a sheet with a numerical value in the next column over. I would like to use the last occurence - or as far as that goes, the largest occurence of the numerical value. Unfortunately, there is additional data in between the "Run #" occurences, so a simple max() for the column will not work.
How To Remove Text After The Second Instance Of An Asterisk?
I'm trying to convert variable length strings which are being copied from a display and loaded into an array.
I have it working fine for the majority of the data, which comes in looking like "*ABC@US" or "*AABC@US"
However, some of the data looks a bit different, particularly lacking the @ symbol. So what I end up with is
"*ABC US*ABC US*ABC US"
What I need to get to is just "ABC US" FYI the US part can be 1-5 characters.
SO... I need a way to truncate anything after the second instance of the asterisk. Haven't been able to get it to work using various trim, mid, len, left, right, etc functions.
VBA Code To Find The Last Instance Of A Value In A Range
I have a worksheet with a column that lists the city where an item is located. If the city is say Austin I need to find the last cell in the range that has Austin in it. I can find lots of examples where you can find all instances within the range and to find the last cell in the range that has any data in but nothing that tells me how to find the last cell in the range that has a specific value.
How To Activate Workbook In Separate Instance
-I've been trying to get an answer to this problem for some time and I would like to try again from a different approach.
I may have 5 workbooks open in 5 different Instances of Excel. The number of files open varies. When the below Function is called, it checks to see if the file, trying to be opened, is already open or not.
Currently, if the file is already open, a mesage is displayed stating that it is open and the user has to search through tabs looking for the file so that it can be displayed.
What I want to do in place of a message, is activate the file that is already open and display it. No message necessary.
I have tried "Application.Activate" and can not make it work.
Finding Cells With First Instance Of Number
I've got a very large spreadsheet wherein I need to write a formula for each row to find the first cell with any entry greater than 0 and then add to that cell the contents ONLY 5 cells contiguious to it.
For example data set is this (in .csv format for you)
Name, Jan01, Feb01, March01, April01, May01, June01, July01, Aug01, Sept01, Oct01, Nov01, Dec01, Jan02, Feb02, March02, April02, May02
I need formula to find first instance in each row of entry greater than 0 and then add to that the contents of next 5 cells.
Jones would find the 5 and then add the 2,7,9,3,10 to it for formula result of 36
Smith would find the 3 and then add the 8,17,23,9,3 to it for formual result of 63
Search For First Instance Of Text & Return The Value
I have a list of product numbers in col. A. In col. O I have a list of file
names that contain the product numbers as well as additional characters. I
need a formula that will search col O for the first instance of the text in
cell A2 and return that value.
The next formula will return all instances that contain the text found in A2.
CSV Files Open In New File Instance
I regularly process CSV files that are downloaded from various websites. The problem is, for some reason many (but NOT all) downloaded CSV files do not open in "Microsoft Office Excel" and thus, my primary workspace. They instead open in a separate instance of "Excel.exe" which is actually kinda nice because I can treat each separately, move windows around, etc. The problem is, macros that are in my primary workbook, cannot be seen by the secondary instance(s). So while I have created a number of nifty macros to clean up all the data and format it exactly how I want it in the blink of an eye, I can't run them when a file opens in its own instance.
1) How can I force ALL .csv files to open in the primary "Microsoft Office Excel" application? NOTE: Using the normal Windows Explorer "Open With..." function and setting the default application only works for LOCAL files, and does NOT work to control how remotely downloaded .csv files are opened.
2) How can I make it so that macros can be seen between Excel instances - such that when I choose to see macros in "all open workbooks", it will actually see the macros in the open workbook in the other primary Excel instance?
Macro VBA Find Last Instance Of A Word
I have a spreadsheet which I am trying to put in a macro to add a new page (below the current page in the same worksheet) so that users who are unfamilair with Excel can simply do this.
I have got the macro to copy the cells I want and can get it to paste but the issue is I don't always want it to paste in the same place. The current document is 1 page long but it may need to be up to 10 pages long. I am trying to get it to find the last instance of the word "COMMENTS" and then paste the copied info 3 rows below that.
Return Nth Instance Of Text String
I have the following formula that returns the most frequently occuring string in a range. what I would like to do is return the 2nd, 3rd 4th and 5th most common occourance as well. I am not sure if I can do this by adjusting this formula or whether that would be a completely diffent formula or worst case senario it is not possible at all.
obviously this is an array.
Force Workbook Open New Instance
I've created a UserForm which the user exclusively uses to interact with a workbook.
The problem is, if the user opens another workbook, it will open in the same Excel "Process" or "Instance" and the user would have to close the UserForm in order to use the other workbook they opened.
In VBA or some obscure application setting, is there a way to force workbooks to open in a new Excel Process (or new "Instance" of Excel)?
Another possibility would be to code something in the UserForm workbook that, on Workbook Open, would start a new separate Excel process....if that's even possible (can VBA execute a system shortcut or system command string?).
Separating Second Occurrence
I'm having a problem seperating the prices in Colomn H into three seperate cells C,E & G
The first figure in c is easy enough if a little long (any possible tidier solutions?)
The second Im not happy with it is clumsy using the fixed lenght figure "5"
The last I cant figure out probably because Ive done the second incorrectly!
Finally I can not see why figures apear in away team.
VLOOKUP Second Occurrence
I am trying to find a way to return an second answer for a second occurance using a VLOOKUP function. (maybe it can be done with something else?)
ex. range= A1:C3,
A1 = 40CA B1 = 30R2 C1 = TRUCK
A2 = 40CB B2 = 30A1 C2 = CAR
A3 = 40CA C2 = 30B3 C3 = TRAILER
VLOOKUP("40CA",A1:C3,3,FALSE) Returns "TRUCK"
How can I get a formula like this to return "TRAILER" the
second occurance of "40CA"?
Formula To Calc Total Hours For Each Instance
I want to find out how many hours, in total, relate to "consolidation 1, 2, 3; Lease Renewal 1,2 3 etc. What formula can I use. I am working on a "sumif" but it's not working out for me.
1 Consolidation 4.75
3 External Sublea
3 Consolidation 2
3 Special Project
2 External Sublea
1 Lease Renewal w
1 New Lease w/o T 4
1 New Lease w/o T 1
1 External Sublea
3 Lease Renewal w 1
2 Lease Renewal w .5
Find Last Instance Of A Word And Insert Blank Row
I would like to be able to add vb code to my developing macro that searches within 1 column for the last instance of a particular word, then inserts a blank row under that word. All the data is sorted, so the words will be used multiple times, but I need the row to go under the last instance of each word in the column.
Search Down The First Column And Find Any Instance Of The Letter
I have this piece of code
Dim i As Integer
Dim x As integer
x = 5000
i = 1
Do Until i = x
If Cells(1, i).Value = "C" Then
i = i + 1
I want it to search down the first column and find any instance of the letter C and shift it (along with the entire row) over two clumns to the right.
List First Instance Only Ignoring Blanks In ROWS
I have a set up of investments. Say A1 through to G1. Then on the next row the investments range from A1 to G1 again. This continues down many rows. There are spaces such as D1 and D2 through E2.
Starting in column H, I would like to list the investments but ignore investments that have already appeared on the row (ie list only the first occurence) and ignore the blanks as well. For example, D1, E1, F1 are to be ignored because of the blank, and the fact that ausbil and amp already appear.
In row 2, the blanks in D2 and E2 are ignored as well as the repeated 'amp' in F2. So the table should look like below from column H:
Is there a simple formula for this? It has to be in rows as I have at least 60 columns of data before these columns begin. There are at least 300 rows.
Create Instance Of Microsoft Windows Journal
1) When using the command below, how can I determine what the "XYZ" component could be. I see plenty of examples of it being used to start a MS Word session or Powerpoint but I'd really like to see a definitive list.
At the moment, I'm not even sure what to type into Google that describes this part of the command's argument.
Set target = CreateObject("XYZ.Application")
2) I'm just a frightened noob on this site and I tried to follow the advice on bumping my previous post on this subject, having altered my plea. All I got was a telling-off for being a double-poster and my old old thread sat where it was despite my 'Bump' command. Do you have to have at least one reply before your thread moves?
1st Occurrence Of Non Blank Cell
I have data across rows in which I want to find the 1st occurance of a non blank cell and return this as a reference.
The formula in col A was kindly provided by Aladin, this finds the last entry, can this be tweaked? I'll be honest and say that I dont't quite understand how it works.
Row 5 should return 2
Row 9 should return 29
Drop Down. Return One Occurrence
I need to know how to create a drop down menu from a very large spreadsheet of Column A but have it only return 1 occurrance. NOT in VBA.
Column A - these are different Value Streams PMV, SMV and WRV but this will show up over 100 times each as there are many departments per Value Stream I would only like to see 1 occurrance
Column B - Is a list of departments per value stream but will have duplicate departments Example: PMV - PM9, PMV - PMA, PMV - PMB
I would like to have a drop down and be able to select from the three value streams (Column A) and it return one occurrance then the departments that correspond with the Value Stream (Column B).
Consecutive Value Occurrence Count
I have to calculate bonus payments for people working O/S. I have a 5 year calendar in month blocks (60 months/columns). In each month there is a percentage 'time O/S' figure.
If an employee is O/S for 3 consecutive months they get bonus 'A', 6 consective months bonus 'B', etc. How can I evaluate the 60 columns, returning the number of times 100% occurs in 3 consecutive months/columns. I have found examples of similar solutions but they will return a value of 3 if there are 5 consecutive months of 100%...
ie. 100 100 100 100 100
= 100 100 100 *** ***
& *** 100 100 100 ***
& *** *** 100 100 100
but I need it to equal 1
Counting The Repetitive Occurrence Value
i want the formula to be used in excel to make acounter in another column for the values the occured repetitively
like to have these two column.
here the operation no is the counter for the repeated work center whose name is paint sh
Formatting From The Second Occurrence Of A Number
I have an worksheet where I use sequential numbers in column B but it often happens that we insert some more rows with the same number in the B column.
Now we would like to have a macro that will format the text color (change to white) in columns B & D as soon as there is a second (or more) occurrence(s) of the same preceding number.
01 – Black (unchanged)
02 – Black (unchanged)
03 – Black (unchanged)
04 – Black (unchanged)
04 – White (changed)
04 – White (changed)
04 – White (changed)
05 – Black (unchanged)
06 – Black (unchanged)
06 – White (changed)
Counting Every Nth Occurrence (with & Without A Condition)
I have a few dozen columns of data and would like from each row to count the number of negative numbers in every 3 occurrences. E.g. in row 2 I’d want to count the negative occurences in B2, E2, H2, K2 etc. Also, I’d like to be able to count the total number of occurences along each row, again counting every 3rd occurrence, though this time both negative and positive values.
Count Occurrence Of Find
In one column, i get the ID. In the next column of the same row i get the status. My question is to find the number of occurrence of a specific ID with a specific status on another sheet. Attached worksheet sheet "count" has the source with ID at column C and status at column D. My expected result is in another sheet "expected result". I think a macro is needed, but i can't really figured out the way to do this counting.
Macro:finding Next Instance Of Text Using FindNext Method
I am facing problems with finding next instance of text using FindNext method. Kindly find code belowe which i have used.
Set srcCell = SourceBook.Worksheets(1).Columns("A").Find("Risk", After:= Sheets("SubArea"). Range("A21"), LookIn:=xlValues, lookat:=xlWhole)
'Set srcCell = SourceBook.Worksheets(1).Columns("A").FindNext
Set firstsrccell = srcCell
Do While Not (srcCell Is Nothing)
tgtCell.Offset(tgtRow, 0) = srcCell.Offset(-1, 255)
tgtCell.Offset(tgtRow, 1) = subAreaId
tgtCell.Offset(tgtRow, 2) = srcCell.Offset(0, 1)
tgtCell.Offset(tgtRow, 3) = srcCell.Offset(1, 1)
tgtCell.Offset(tgtRow, 5) = srcCell.Offset(3, 1)
tgtCell.Offset(tgtRow, 6) = srcCell.Offset(2, 1)
Set srcCell2 = SourceBook.Worksheets(1).Columns("A").FindNext
' If firstsrccell.Address = srcCell.Address Then
' Exit Do
' End If
tgtRow = tgtRow + 1
I checked above code by putting breakpoint, but code is unable to find next instance where it matches the required string (FindNext reamains at the same position).
Multiple Instances (VBA To Open 3 Workbooks In Their Own Session/instance)
I'd like to use VBA to open 3 workbooks in their own session/instance/etc of Excel 2007. Ideally, there will be one main workbook, that upon opening will subsequently open the other 3 workbooks.
Also, when I open that first main workbook, I will obviously have to enable macros to get any code to run. Is there a way to carry this enabling of macros over to the other sessions to avoid having to enable macros in all 3 other workbooks? (Changing my security settings isn't an option)