I have worksheet A:
I have another worksheet (WS) B:
What I want:
I wanna use a Vlookup formula at cell C3 with the formula like this:
=VLOOKUP(B2,b!A2:B3,2,FALSE)
However:
I don't know how to make it look up multiple comma separated values (csv) in one cell (Note that there are cells that can go up to 10 csv)
Logic wise, cell C3 of WS A should :
Lookup value B2
From the table array of WS B
Looping through cell A2 of WS B, it should check for "1-ABC", "2-ABC", "3-ABC".
Since it finds a match at "3-ABC" then C3 will return the Unique Acc ID at B2 of WS B
Then hopefully I can drag down the formula to many many records...
Can this be done using formula or it better to do it via VBA? If VBA, how can I do this?
You can use the asterisks as wildcard like that
=VLOOKUP("*" & B2 & "*",b!A2:B3,2,FALSE)
Related
Still a newbie with VBA coding. I have a code to search input text or word (ignore case sensitive) from a multiple worksheet, text/word can be within a word (ex. ben from Benjamin). So far, i have the result of search in column B2, C2, D2 and so on until done. the value in column B2, C2, D2 have same format WS.name & cell address in the form of dog$B$, cat$D$32, horse$F200, etc. I want the Display output into a Master worksheet to column A3:whatever. The output should consist of that entire row including bland cell upto column Z. Also if the worksheet name is calling for "chart" I also need the value of the rows from 3 rows before and 2 rows after.
I have a spreadsheet with two worksheets, A & B.
I need a formula that will look at a value in cell B2 in worksheet A and return the value in cell F2 in worksheet A to cell C2 in worksheet B.
So. If the value in B2 is individual the formula will return the Value in F2, e.g., "Smith", to cell C2 in worksheet B.
How can I do that?
So, like this:
=IF('Sheet A'!B2="individual",'Sheet A'!F2,"Blank")
I'm using Excel and I've just started using vba in Excel.
I need to add the values of column I, cells I6:I26 in sheet 1 to column D, cells D1:D21 in sheet 2.
So if I6 = 4 and D1 = 6, and I press the ADD button, D6 will equal to 10. Same goes for the rest of the cells.
I don't want it cell I6 to replace the value of D6, I want it to add to it.
This is the code I have so far for it;
Dim r1 as Range, v as variant
Set r1 = Sheets("Sheet2"). Range("D1")
V = Application.WorksheetFunction.Sum(Sheet1.Range("I6"), Sheet2.Range("D1"))
R1 = v
I had to do that 20 times..is there anyway to simplify this?
You can Evaluate the sum of arrays:
[Sheet2!D1:D21] = [Sheet1!I6:I26 + Sheet2!D1:D21]
I'm finding it a bit confusing where you want the result to go. Sheet1 has data in I6:I26 and Sheet2 has data in D1:D21.
You want the first result to go into cell D6... on what sheet? On Sheet2 so it starts overwriting the old data, in Sheet1? Some other sheet?
This code will place a formula in cell D6 on sheet 1 and drag it down to cell D26.
I've given two types of formula. A1 notation and R1C1 notation.
A breakdown of the R1C1 notation:
RC9 means take data from this row, column 9 - in cell D6 this will be cell I6.
R[-5]C4 means take data from 5 rows up in column 4 - in cell D6 this will be D1.
Sub Test()
With Sheet1
.Range("D6").Formula = "=SUM($I6,Sheet2!$D1)"
'You could also use R1C1 notation (which is easier if you're looping through rows/columns).
'.Range("D6").FormulaR1C1 = "=SUM(RC9,Sheet2!R[-5]C4)"
.Range("D6:D26").FillDown
End With
End Sub
I'm having multiple sheets in an excel file
sheet1 contains some data from A1 to A100
sheet2 in this sheet row1 contains the data with numeric value
in sheet2 if A1 contains the 0 A3 should be the value of A1 of sheet1
in sheet2 if A1 contains the 30 A3 should be the value of A1+30 that is A31 of sheet1
Any idea how to get the described behavior?
It sounds like you're looking for something involving INDIRECT. Not sure what your data looks like, but from what it sounds like, you would want to put a formula like this in A3 in Sheet2:
=INDIRECT("Sheet1!A" & A1 + 1)
That will get the value in A1, add 1 (0->1, 30->31) and then concatenate it with the Sheet1!A string, giving you a reference to a cell on the first sheet. Using INDIRECT then returns the value at that cell.
It Sum of columns is storing in one cell and if I want the same answer to be printed in another cell, what is the formula to get this?
Let's say your sum is stored in B1 and you want same in C1 then you can do
=B1
inside C1 cell
Let's say you want the value of cell A1 in cell B1. You would use this formula in B1:
= A1
In code you would write something like this (example in VBA):
Dim sht as Worksheet
Set sht = ThisWorkbook.Worksheets("MySheet") //Or whatever your target sheet is
sht.Range("B1").Formula = "=" & sht.Range("A1").Address