I have a spreadsheet of all of the site-to-site VPN tunnels we have in production. I'm attempting to create a table like the following in Excel, where Source and Network are already known, and Destination is an output of the two. Essentially in the Network Column there are 2 (and no more than 2) instances of each network address. I would like to create a third column (the Destination OUTPUT) column to output the other half of a matching pair, so to speak. I feel like this should be some sort of VLOOKUP but I cannot for the life of me figure out how to format it. The goal would be to do it without needing to create another helper column or anything like that. I know I could use some functionality in Kutools to do it, but I'm trying to keep the sheet dynamic rather than relying on a macro that makes a static edit to the sheet.
Source
Network
Destination (OUTPUT)
Ashburn
1.1.1.0
San Jose
Dallas
4.4.4.0
Seattle
Vancouver
2.2.2.0
San Jose
Frankfurt
3.3.3.0
Chicago
San Jose
1.1.1.0
Ashburn
Chicago
3.3.3.0
Frankfurt
San Jose
2.2.2.0
Vancouver
Seattle
4.4.4.0
Dallas
Thanks for any help you can provide!!
EDIT: So I'm trying to use INDEX() and MATCH() for this now and I think I'm getting closer...
=INDEX($A:$B,MATCH(B2,B:B,0),1) returns the first match, which is just itself. How might I modify my MATCH statement to select the second match? And will this search the entire list and then start from the beginning again until it finds the second match? Or would it only work when ordered in a certain way?
Thanks!
If you have Office 365:
C2: =FILTER($A$2:$A$9,(B2=$B$2:$B$9)*(A2<>$A$2:$A$9))
You can also use, in any version of Excel: (as suggested by #JvdV)
C2: =LOOKUP(2, 1/(($B$2:$B$9=B2)*(A2<>$A$2:$A$9)),$A$2:$A$9)
(Normally entered)
This will work in all versions of Excel, entered as an array formula if you don't have dynamic arrays:
=INDEX($A$1:$A$9,MAX(IF((B2=$B$2:$B$9)*ROW($B$2:$B$9)=ROW(),0,(B2=$B$2:$B$9)*ROW($B$2:$B$9))))
Related
I have a list of cities (this is a simplified version)
London
Manchester
Nottingham
I want to say something like (Obviously formula is not correct, is just to show what I am trying to do)
=COUNTIFS(MachineData!$X:$X,"Y",MachineData!$N:$N,"*london*" OR MachineData!$N:$N, "*Manchester*" OR MachineData!$N:$N,"*Nottingham*")
Basically, I want to count if its London OR Manchester OR Nottingham but also if X:X is Y
How can I do this without having to repeat the same instruction 3 times? is there a way to do this where I can tell it to check all the conditions for the cities at once?
Update: I have been trying something like
=COUNTIFS(MachineData!$X:$X,"Y",SUM(COUNTIFS(MachineData!$N:$N,{"London","*Manchester*","Oxford","*Nottingham*"})))
But this is not working for me
You are very close to a solution yourself. Try:
=SUM(COUNTIFS(MachineData!X:X,"Y",MachineData!N:N,{"*london*","*manchester*","*nottingham*"}))
edit: Use #JvdV solution. Far more elegant, less wall of text.
I created a small table as an example, five lines long reading london, manchester, nottingham, cardiff, london. The table name is table1, the column header I used was "target city"
With that in mind, this will bring the desired results into a single cell.
=SUM(COUNTIF(Table1[Target city],"london"),COUNTIF(Table1[Target city],"manchester"),COUNTIF(Table1[Target city],"nottingham"))
Result = 4
Warning: Depending on the length of the target cities you want to bring in and how frequently that list changes this might become prohibitively large/time consuming.
If you need something that will dynamically scale based of a changing list of cities you want to look for, something like python may be a better solution.
No, COUNTIFS is restricted to AND and cannot use OR.
=SUM(COUNTIFS(Table2[Category 2],"Y",Table2[Category 1],{"London","Manchester","Nottingham"}))
Suppose you have the following named ranges:
There are a couple of ways to crack this question:
Solution1:
=SUMPRODUCT(((N:N=City1)+(N:N=City2)+(N:N=City3))*(X:X=Criteria1))
For this type of question, I normally use SUMPRODUCT as a first instinct, but it is not as fast as using SUM+COUNTIFS if you are working on a large dataset.
Solution2:
=SUM(--ISNUMBER(MATCH(N:N,Cities,0)*MATCH(X:X,Criteria1,0)))
Instead of checking on individual cities, it would be faster to put the cities in a named range and check all of them at once and then add the results up.
Solution3:
=SUM(COUNTIFS(X:X,Criteria1,N:N,TRANSPOSE(Cities)))
This is the solution proposed by JvdV using named ranges.
Solution4:
=SUM((N:N=TRANSPOSE(Cities))*(X:X=Criteria1))
This will do the trick too, but I am not sure how it compares to SUM+COUNTIFS in terms of calculation efficiency on a large dataset.
Although I have some experience in VBA I still consider myself a novice. Just something to keep in mind.
I have a monthly report of a workbook with three worksheets that I am writing a macro for to combine and restructure the file for the output. My issue is that I have data in one column that contains information that I must extract some text, change the case and write back to the same cell. The text is, generally, a company name which will not start in the same location from company to company. Since VBA does not use wildcards (something I am accustomed to) I am finding it difficult to formulate a means to attain my task. I thought, once I located the 'name' I could reference a table and extract the modified name I need and rewrite to the cell. Here is an example of some input:
Col A Col B Col C
ASTRO #256 ASTRO Astro
DEBIT PURCH VISA CHEVRON 02 CHEVRON Chevron
SMART FOODSERVICE SMART FOOD Smart Foodservice
The value in column B is what I need to find in Column A and then take the value from Column C moved to Column A
I know I can do countless IF ELSE nests but I would rather have a separate table of col B and C in which to add new accounts as they arise. But that would require the code to be generic enough so the only updates are to the table and not the code. I understand I may be forced to do both but I suspect there is a more efficient way to do this.
Any thoughts? Thanks, Jeff
I have created a questionnaire that consists of around 100 questions. Participants are asked to fill them in online, where the items are shuffled each time. These items are separated into 6 domains where, for the sake of easier understanding, let's just call them Domain 1 - 6.
I have them typed in one specific table called "Correspondence", with format like below:
(An example)
Question No.|Domain
1 |Domain A
2 |Domain C
3 |Domain A
4 |Domain B
5 |Domain A
6 |Domain C
I used Google Form to generate a spreadsheet of RAW data of respondents, where it will help me mark the RAW Scores, for each item on a separate column:
(An example)
Submission ID|Question 1|Question 2|Question 3|Question 4|Question
5|Question 6
Participant 1 | 2 | 3 | 5 | 1 | 2 | 4 |
Participant 2 | 5 | 4 | 5 | 3 | 5 | 1 |
Participant 3 | 1 | 1 | 1 | 2 | 2 | 2 |
The next thing I need to do is generate another table that sums up the Domain totals for each participant. So from the example above, I need to sum 1,3,5 as Domain A, 4 as Domain B and 2 & 6 as Domain C:
(An example)
Participant 1
|Domain A|Domain B|Domain C|
Total | 9 | 1 | 7 |
The hardest thing is to find a proper method to kick start this process. Can anyone point me in the right direction? Either formulas or VBAs would be fine too. Thanks!
This can be done if you are able to create a helper row.
First, I created a table to link the question to domain. That is named in my example as "Correspondence". This table is somewhat the answer key. From your description of the problem, you need a table like this to establish which question is associated with the domain/category/point system you want to use.
I then created a helper row for the survey results shown on row 9. This has =INDEX($B$3:$C$8,MATCH(B$10,$B$3:$B$8,0),2) in cell B9 as the code to reference the question to the domain. This is immediately above the questions in the example, but you can put it on a separate sheet if needed.
Then you can just sum them up.
=SUMPRODUCT(SUMIFS(INDIRECT(MATCH($E3,$A:$A,0)&":"&MATCH($E3,$A:$A,0)),$9:$9,F$2))
This formula uses MATCH, which returns an integer, inside INDIRECT to be used as a dynamic row reference. This will fail if the participant names are not unique. The SUMIFS inside the SUMPRODUCT allows the row to be treated like an array without using an array formula. So you can recreate the example I have and copy/paste or drag and paste the formulas as you wish.
A different approach may be that you want to sum up the points to the questions first and then do the conversion from question to domain. That way you don't ever have to manipulate the raw data, just the reports. That may be the better approach for you, actually.
Edit: Added information about the formulas and the example.
How do I extract text between two commas in Excel?
92 4th Street North, Providence, RI 02904
In this case, how would I extract "Providence" substring using simple Excel formulas (LEN, FIND, LEFT, RIGHT, etc)?
Try the following formula.
=MID(A2,FIND("^",SUBSTITUTE(A2,",","^",1))+1,FIND("^",SUBSTITUTE(A2,",","^",2))-FIND("^",SUBSTITUTE(A2,",","^",1))-1)
Try the following formula
=LEFT(RIGHT(A1,FIND(",",A1)),FIND(",",RIGHT(A1,FIND(",",A1)))-1)
Considering your data is on A1
#RAJA-THEVAR's formula worked very well for me with a list of over 2500 addresses, as long as the address only contained two commas. With an address like "100 Washington Street, Suite 225, Denver, CO 80220" it returns "Suite 225." I used the following formula to identify and addresses that contained more than two commas:
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))
Many of these many-comma addresses had strange formats or information, and I found it better to fix them by hand.
I've tried finding a formula but really just can't seem to find it at all!
My problem is i have thousands of addresses in different structures but i need to find the city in each of them!
So the different types of addresses i have are as follows:
Dornocktown, Dornock, Annan, DG12 6SU
Grainshore Road, Hatston, Kirkwall, KW15 1FL
Brandon Road, Watton, Thetford, IP25 6LW
Bainbridge, Leyburn, DL8 3EP
Shore Road, Dornoch, IV25 3LS
Boston Industrial Estate, Power Station Road, Rugeley, WS15 2HS
Parkfield Road, Wolverhampton, WV4 6EH
I need the city or the last word before the post code.
Any help would be great thanks!
Try this, values in A1:A7:
In B1 write:
=RIGHT(A1;LEN(A1)-1-FIND("#";SUBSTITUTE(A1;",";"#";LEN(A1)-LEN(SUBSTITUTE(A1;",";""))-1)))
copy till B7
now in C1 write:
=LEFT(B1;FIND(",";B1)-1)
copy till C7
Now you have the city names. It is possible to do everything in one formula but will be a very big one...
Depending on your settings you may need to replace ";" by "," for field separators