This question already has answers here:
Find last used cell in Excel VBA
(14 answers)
Closed 6 years ago.
I met a little problem when I use:
Count_line = ActiveSheet.UsedRange.Rows.Count
to count how many lines do I have in a worksheet. It can not give me the correct number. Can it be influenced by the format of the cells? Cause I've different coulour to highlight some important columns.
If you've got sime idea, please leave a comment. Thank you!
UsedRange.Rows.Count is not a reliable way to pull the last row, as it doesn't account for empty rows at the start of your sheet. Assuming you are finding the last row with text in it, use the End method to find the row.
Related
This question already has an answer here:
Excel VBA Formula German/French/Italian/Russian/Dutch/Foreign Function
(1 answer)
Closed 3 years ago.
I'm making a bot that erases certain columns and fills them in with new data. By erasing the data, the formula becomes
=IFERROR(INDEX('AP query'!O:O,MATCH(Findings!#REF!,'AP query'!L:L,0)),"Non PO")
So I tried making a macro and filling the cell with the formula but it says there's an error. Is there a fix or another way to enter the formula into the the cell using macros?
Range("B3").Formula = "=IFERROR(INDEX('AP query'!O:O,MATCH(Findings!C3,'AP query'!L:L,0)),"Non PO")"
srcWorkbook.Worksheets("Findings").Range("B3").Copy
srcWorkbook.Worksheets("Findings").Range("B3:B" & LR).PasteSpecial xlPasteFormulas
When you wish to use a string in a formula =IF(A1="Hi",... in VBA, just "double up" the quotes:
Range("B3").Formula = "=IFERROR(INDEX('AP query'!O:O,MATCH(Findings!C3,'AP query'!L:L,0)),""Non PO"")"
Because, as VBA compiles that line, it'll hit the first quote at "Non Po" and think that's the end of the line. So (...trying to visualize it), it'd be reading that line like your formula is:
=IFERROR(INDEX('AP query'!O:O,MATCH(Findings!C3,'AP query'!L:L,0)),
Tangiental tip - sometimes when I hit similar issues, even just pasting the code here on SO, and formatting it as code, helps because as you can see in your post, the Non PO is a different color, but all formulas (strings maybe?) should be the same (all red, as in the answer I posted above).
I have the following scenario:
If cell I2 has a value, I want cell I3 to be equal to D3 and continue until 2 years (=C3), then next 2 years (=E3-C3) as $1 (=F3), then next 2 years (=G3-E3) as $3 (=H3).
I want the following as shown below in I3 to T3. How to do this in excel?
Thanks
I'm not quite sure I understand the purpose of triggering a reset of the phase costs so I won't include that in my answer until you review your question to properly explain it. Otherwise, see my answer below.
I would think a separate table is more concise for display values and lets you extend easier without adding columns.
I changed from year number (1-6) to year (2019-2024) since that's what you are displaying. I then used an INDEX MATCH but used the lookup argument of 1 to allow matching values greater than the year start.
EDIT
In order to do what you would like, I had to set a start and end range on the left side. Please recreate the formulas in your workbook.
This question already has answers here:
How can i count cells in excel? Need to count how many say win, and how many say loss [closed]
(2 answers)
Closed 5 years ago.
I am interested in Libre Office Calc, but it's perhaps similar or even identical as in Excel.
So, let's say I want to know how many cells in the column A have something in them.
How to count how many rows with some value are in the column A?
And I would like to display the result (number of cells/rows with somthing in them) in a B1 cell.
Any idea how to do it?
Try,
=countif(a:a, "something")
count is the way to go, theres a few versions, either
=countif(a:a,"value to count")
place what you want to count between "" unless its a number then dont use the ""
or
=counta(a:a)
will count anything with something in (includes text and numbers)
or
=count(a:a)
where only counts numbers
This question already has answers here:
Pulling data from big excel datatable with incremental column in Vlookup or IndexMatch without zeros
(2 answers)
Closed 6 years ago.
I'm not using a numerical formula. All I have is a simple reference to another cell.
=(Sheet1!D8)
If that cell is blank, I want to have the cell on this page blank too, not a 0. How do I do that? I want it to appear empty to anyone, not just me, so I don't think simply editing excel settings would work? None of my google search results, including MS office site, have been helpful.
My suggestion:
=IF(ISBLANK(Sheet1!D8),"",Sheet1!D8)
You can force a formula to evaluate as text instead of as a number by adding '& ""' to the end like below, but if you are dealing with numbers this isn't great.
=(Sheet1!D8)&""
See this answer for other ideas.
This question already has answers here:
Find last used cell in Excel VBA
(14 answers)
Last not empty cell (column) in the given row; Excel VBA
(2 answers)
Closed 8 years ago.
I have a range of data that will be between columns B and D inclusive.
I can get the top left most range as this will be constant, the only thing that varies is the bottom right cell.
I tried obtaining the bottom right cell via using xltoright and then xltobottom. However I am having difficulties obtaining the cell address of this bottom right cell.
Has anyone come across this problem and if so how did you over come the issue?
change xltoright and then xltobottom, to : xltoleft and then xlUp.
Check the answers you get from it in the immédiate window of VB editor (Ctrl+G)
if still doesn't work maybe use:
Range(Range_Adddress).cells.(Range(RangeAddress).cells.count).address
to get to the last cell's address of your range (I named it Range_Address, which has to be a string in the example).
Does this help you?