I have a formula in excel that looks like such: =COUNTIF(Imports!$B$2:$B$999,"1")
It works like I want it to but part of my manipulation of the spreadsheet requires me to insert new columns in the sheet that formula is referencing. When I do that it changes the formula from column B to column C which is actually not what I want. I want it to reference column B no matter what. How would I achieve this in Excel? Thank you!
Use INDIRECT to reference range from its text address:
=COUNTIF(INDIRECT("Imports!$B$2:$B$999"),"1")
Related
Is it possible to Vlookup a value and copy the entire row that matches
For eg: if I am searching for id=1234 in sheet A
1234 ABC DEF HIJ
The Vlookup should return the entire values.
I am trying to apply this formula in alternate rows of a sheet-The look up value is always in Column A (in the row just above).
Is this possible?
I am a novice in Excel VBA and any help is much appreciated.
Thanks
You would need a separate VLookup for each piece of data
=Vlookup($A1,Sheet1!$A:$C,Column(Sheet1!B:B),false)
If you use this code in the first cell and copy it across it will give you the correct formula for each piece of data.
I have assumed that the data you are searching for is in cell A1 of the current sheet and that the data you are searching is in Sheet1 between Columns A and C. You will need to modify these values if you are doing something different.
To get the position of an item use the Match Function instead of Vlookup.
position = WorksheetFunction.Match("1234", Worksheets("yoursheet").Columns(1), 0)
Now you can use the position to copy the entire row like
Worksheets("yoursheet").Rows(position).Copy
I'd like to Round the data in my worksheet. I need to add #round(cell,-3) where cell has a unique function that I don't want to disturb.
AFAIK, I can't use any of the formulas extant in Excel.
Ideas?
Apply a custom format to the cells as 0, (Solution by John Walkenbach)
I have a worksheet with a large number of tables. Every other table is formatted the same. Each row has set columns that will not change with regard to the formula. Say... =(A * B / G) - D
I'm trying to figure out a way to write a Worksheet formula that I can cut and paste without having to alter the row reference in the formula for it to work. That way I can copy and paste the formula into each table since I cannot click and drag it down the whole worksheet.
Ideally, I'd like to keep a list of formulas in a text file that I could just cut and past and not have to alter. I would be really cool if I could do something similar for using UDFs that can figure out the Range(Cells()) location on its own.
I'm using . Thanks!
=ROW()
but from your description I am not sure why you can not copy something like $A1 down and let the 1 update as it goes down each row. Take a look at what the effect of the $ symbol before the column or cell reference does. It prevents the column letter and/or row number from changing as cells are copied from one location to another.
ROW() will return the row number of what row it is in, or the row number of a reference if you supply the reference address:
ROW(AS134) will return 134.
To use this, you would most likely need to combine it with something like INDIRECT:
=INDIRECT("A"&ROW())
That formula would reference column A and the same row as wherever the formula was placed. HOWEVER, INDIRECT is a bad choice if you are using it frequently as its a volatile function and will recalculate anytime something on the worksheet changes. As per Scott Craner's suggestion, INDEX is a non volatile function so it will not force the recalculations and would look something like:
=INDEX(A:A,ROW())
Ex.
column A is a formula that outputs an 8 digit ID from a prior delimited calculation. I want to vlookup that ID to a separate set of data, but it is not finding the ID when the lookup value is part of a formula.
Is there a way to paste the formula result as a value in column b?
I have a list of 3000+ IDs, so using the F2, F9 trick won't work, since I would have to do that cell by cell.
Would prefer not to use VBA, but if that is the only way, can someone help simplify that process (new to using VBA)
If you have data in column A based on a left function of a bunch of numbers, and just want that result in column B, all you have to do is put:
=Value(ColRow)
in Column B. Then you can look up the value in Column B via VLookUp.
I am an avid Excel user and personally tested this solution. Though it appears #Scott beat me to it in the comment section.
I've not written any macros for some years so am rusty.
With Excel 2007 I need go through a whole column of data (assume it's column A) and for each cell in that column try to find the value in column C of another worksheet.
Can Vlookup do this or would I need to use another function?
A basic example using a second sheet reference (Sheet2), with a range in column A:
=VLOOKUP(Sheet2!C2,A2:B5,2,FALSE)
Below is a working screenshot example:
Useful Reference
VLOOKUP function