Is there an excel formula like INDIRECT to get a dependent drop down from another workbook? - vba

How can I get dependent dropdown in cell D2 based on dropdown value chosen in cell C2 in Workbook1 from Workbook2? The INDIRECT method seems to work for different sheets in the same workbook. Couldn't find a method that worked for different workbooks.
Example -
C2 value - Services, D2 should load - Third party service, and so on
C2 value - Medical Devices, D2 should load - Dosimetry and so on.
These values are in Workbook2. I successfully loaded values in C2 but can't load dependent values in D2. How can I load the dependent values?

I'm not sure why you feel that you need INDIRECT but I just got an example working without it.
(INDIRECT should generally be avoided for a number of reasons.)
test.xlsm :
A1:A5 populated with A,B,C,D,E
Drop Down 1:
Input Range: $A$1:$A$5
Cell Link: [Book2]Sheet1!$A$1
book2.xlsm :
A1 = cell link
Drop Down 1:
Input Range: [test.xlsm]Sheet1!$A$1:$A$5
Cell Link: $A$1

Related

Extract data from another workbook using VBA

I have two workbooks.
In Workbook A, I want to find the value in cell A11 (sheet 'Data') in column A of Workbook B and then return the corresponding value in column H. THis value must be pasted into Cell C11 in Workbook A.
Workbook B must be opened and closed to extract this data without the user having to manually open it.
How do I use a VBA code to achieve this? Preferably variables are built in based on values in workbook A e.g. path, file name, worksheet name, column A in above example and column H in above example).
Link to Workbook A: https://www.dropbox.com/s/e6ixr5ky4i2r6vw/Data%20extraction.xlsm?dl=0
I'm using MS Office Excel Professional Plus 2010. As long as the user won't be storing file B where he can't access it again, Excel can manage this without the need for VBA.
In cell C11 in workbook A type "=" to begin writing a formula. Now switch windows to workbook B and click cell A11 on sheet 'Data'. Hit 'Enter' on your keyboard... the computer should return to workbook A.
The formula in C11 now should show the filename of workbook B and the cell reference.
Now's when the magic starts: Excel has made this formula into a "Data connection" and will work behind the scenes to keep this cell updated. It may give you a yellow bar asking to activate automatic data updates, which you should accept.
Test and see if this method satisfies your requirement. If workbook B is stored in a shared location, do more testing to see if that doesn't mess it up.
Good luck!

VBA to jump to certain cell after changing contents of one

I am creating a spreadsheet that I want to force people to input certain information. Is there anyway of forcing people when changing the contents of a cell that once return or tab is entered that it jumps to another cell.
For Instance:
CELL C2 (Date) 01/01/2001
CELL C4 (EMPTY) JUMP HERE
So above I want someone to enter a date in C1 and when they change this is jumps to C3.
Kris
The selection of a specific cell in the first sheet:
ThisWorkbook.Sheets(1).Range("A2").Select
You can use name of the sheet as a string instead of 1 in sheets(1)

Excel SpecialCells(xlCellTypeBlanks) fails with merged cells

Excel SpecialCells(xlCellTypeBlank) includes all cells in a merged range, regardless of whether they are blank. I consider this to be a bug, and I desperately need a workaround. Steps to duplicate:
(1) Create a worksheet with some text in cells A1 and B3. Now activesheet.usedrange.cells.count = 6 and
activesheet.usedrange.specialcells(xlcelltypeblanks).cells.count = 4
These values are as expected.
(2) Now merge cells A1:A2, and
activesheet.usedrange.cells.count = 6 and
activesheet.usedrange.specialcells(xlcelltypeblanks).cells.count = 5
Both A1 and A2 are now considered blank.
I need to find a way to select just cells A3, B1, and B2 in this case. I'm actually doing this using .NET Excel Interop, so I do not want to have to actually retrieve the cell value as a part of the test, since this is a huge performance penalty in Excel Interop; so I'm restricted to an internal cell selection function such as SpecialCells.
I got this to work by selecting smaller ranges at various places in the code, usually just before doing any cell merging. I consider this to be a workaround, not really a solution. Thanks to those who commented - you helped inspire this workaround.

Excel Cell reference that will go to the left

I am using an excel spreadsheet formula to add two cells together and I want to have it reference one row from left to right like it normally does, but I need it to reference the same row in another page in reverse, and then be able to drag the formula through the entire worksheet. I cannot seem to find anything like this when I look online. TLDR I need to know how to tell excel reference the cell to the left if I drag it to the right.
so I need to add A0 in page one and A9 in page two then when I copy the formula to the left I need it to grab A1 and A8, is there a way to get this?
Your question is not very clear; for example, you talk about a formula but have an Excel-VBA tag. However, I think I understand the effect you seek.
I have filled A1:I1 of the current sheet and A1:I1 of worksheet “Sheet3” with numbers.
I have typed the following formula into another cell within the current worksheet:
=A1+INDEX(Sheet3!$A$1:$I$1,,10-COLUMN(A1))
The target area for the INDEX function is Sheet3!$A$1:$I$1. This is a one row range so I do not need a row number. The column number is 10-COLUMN(A1) which is 9 so this formula is equivalent to:
=A1+Sheet3!I9
If I copy the formula one cell to the right I get:
=B1+INDEX(Sheet3!$A$1:$I$1,,10-COLUMN(B1))
This is the equivalent of:
=B1+Sheet3!H9
You can continue copying the formula to the right until you get:
=I1+INDEX(Sheet3!$A$1:$I$1,,10-COLUMN(I1))
Attempting to copy further gives an error because 10-COLUMN(J1) is zero and there is no column 0.
There are other methods of achieving this effect. The key feature of any such method is the expression N-X where N is a constant and X gets bigger as the formula is copied further to the right.

Loop and Grab box to the right

I'm currently working on a project that requires loops which I'm not to sure how to go about doing.. I have the information in blocks so for each client I have a bunch of information so for instance I will have A1 say Name: and B1: say Bob,
Then A17 will be again Name: B17: George
This keeps going for approximately 1000 rows. I need to find a way to circulate through all of the material and grab all the names and place them in a column following each other.
I guess I'm looking for a loop that finds name gives me the value to the right, and then it keeps doing that all the way down.
Anyone have any ideas?
Very simple...........say your names are stored in column B in cells B1, B17, B33, B49, ...basically 16 rows apart...Then in cell C1 enter:
=INDIRECT("B" & 16*ROW()-15)
and copy down. This is good for evenly spaced records
EDIT#1:
Since the records are not evenly spaced..........in C2 enter the following array formula:
=INDEX($B$1:$B$1000,SMALL(IF($A$1:$A$1000="Name",ROW($A$1:$A$1000)),ROW()-ROW($C$2)+1))
and copy down.
This is an Array Formula . Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
Something like:
Adopted from simocos post
in C1 enter this formula : (with Ctrl+ shift + Enter)
= IFERROR( INDEX($B$1:$B$1000; AGGREGATE(15;6;(ROW($B$1:$B$1000)-ROW($B$1)+1)/($B$1:$B$1000<>"");ROWS(C$1:C1)));"")
then copy the cell down
(the formula is not from me. I use it in one of my workbooks, and adapted it)