I'm trying to do an IF formula that compares the value of an offset cell
leadtime_value2 = Range("H3").Value
ActiveCell.Formula = "=IF('ActiveCell.Offset(leadtime_value2,-1)'=TRUE,F7-C8+$D$1,F7-C8)"
As you can see I'm telling my that my cell to compare is the one the number of times Cell H3 value up in rows (Because H3 is negative) and one column left in the active cell value
H3 value is an input from the user
Could you please tell me the proper syntax for this code?
Related
An extended question from the original post: Conditional Hyperlink if Value from Sheet1 Matches Value in Sheet2
Is there any way to hyperlink with multiple conditionals?
Would I need to utilise IF / AND statements? ๐ค
FOR EXAMPLE:
When data in two different columns in Sheet 1, B2 ("Number") and C2 ("Letter"), MATCH two columns in Sheet 2, A2 ("Number) and Column B2 ("Letter"), then cell A2 ("Link") in Sheet 1 hyperlinks to A2 in Sheet 2
I was able to figure it out and wanted to post the logic should it prove to be helpful to anyone else. It's a bit lengthy but wanted to explain as much as possible to [hopefully] assist your understanding ๐:
Formula Used...
=IFERROR(HYPERLINK("#"&CELL("address",INDEX(Sheet2!$A:$A,MATCH(1,(Sheet2!A:A=Sheet1!B2)*(Sheet2!B:B=Sheet1!C2),0))), "Link"),"Hyperlink Error")
Basically translates to...
If any value in Column A of Sheet2 is an exact match to B2 in Sheet1 AND any value in Column B of Sheet2 exact match to C2 in Sheet1, HYPERLINK to that relevant cell in Column A of Sheet2 (A5 in this case) and display "Link" in place of the formula; Otherwise (if error), display "Hyperlink Error"
To break it down...
Formula Syntax :
IFERROR(value, value_if_error)
HYPERLINK(link_location, [friendly_name])
CELL(info_type, [reference])
INDEX(array, row_num, [column_num])
MATCH(lookup_value, lookup_array, [match_type])
Formula Breakdown :
IFERROR
value = the argument that is checked for an error (from HYPERLINK up to MATCH formula)
value_if_error = "Hyperlink Error"
HYPERLINK(link_location, [friendly_name])
link_location = the path and file name to the document to be opened (from "#"&CELL up to MATCH formula)
[friendly_name] = (optional) the text or numeric value that is displayed in the cell ("Link")
CELL(info_type, [reference])
info_type = a text value that specifies what type of cell information you want to return ; various types available but the above formula uses "address" which is a reference of the first cell in reference, as text.
[reference] = (optional) the cell you want information about (from INDEX up to MATCH formula)
INDEX(array, row_num, [column_num])
array = a range of cells or an array constant; Column A of Sheet2
--> If array contains only one row or column, the corresponding row_num or column_num argument is optional.
--> If array has more than one row and more than one column, and only row_num or column_num is used, INDEX returns an array of the entire row or column in array.
row_num = selects the row in array from which to return a value ; (our MATCH formula)
[column_num] = (optional) selects the column in array from which to return a value ; Not used in our formula
MATCH(lookup_value, lookup_array, [match_type])
lookup_value = the value that you want to match in lookup_array ; it can be a value (number, text, or logical value) or a cell reference to a number, text, or logical value ; (the 1 used in our Formula = TRUE ; if FALSE = 0)
lookup_array = the range of cells being searched ((Sheet2!A:A=Sheet1!B2)[asterisk](Sheet2!B:B=Sheet1!C2) where the [asterisk] in the middle denotes "AND", meaning both conditions must be met)
[match_type] = (optional) specifies how Excel matches lookup_value with values in lookup_array where -1 = greater than, 0 = exact, or 1 = less than (our formula uses "0" to look for an Exact Match)
The End Result...
SHEET1
SHEET2
so i have some data in column A, like this,
(A1)12 (B1)
(B2)1
(B3)2
(B4)3
(A5)15 (B5)4
(B6)1
(A7)32 (B7)2
but after each value in column, there are some random number of empty cell and then another value. so the formula i am using is to calculate data between A1 and A5 in column C is
=$A$1+(B2/4)*($A$7-$A$1)
same for the next two values in column A between A5 and A7. ,
but the thing is i have a very high amount of data, is there any option that i dont have to specify cell in the above formulae, it automatically selects the non empty cells in the formulae along with their cell numbers.and cell difference.![enter image description here]
I have data in column A, with a header "Time" in cell A1. I am trying to locate the address of the first cell in column A where the cell value is greater than 1. This should be in cell A12.
However, when using the following code, I get the cell address of $A$1.
=CELL("address",INDEX(A:A,MATCH(TRUE,INDEX(A:A>1,0),)))
gets the address of the first value that is 1 or greater than 1 in column A
="$A$" & COUNTIF(A:A,"<"&1)+1
I want to display the reference of cell based on condition that if the cell contains a value it should display that the cell has a value for example
If cell A1 has a value eg 12, then cell B1 should display โThere is value in cell A1โ else it should be blank
I have tried this this
=IF(A1="","","There is value in cell "&A1).
Does anyone know how I can change it to =There is value in cell A1
Instead of There is value in cell 12
Something like this
=IF(A1="","","There is value in cell "&ADDRESS(ROW(A1),COLUMN(A1),4))
Also if you don't have any issue with the volatility an easier formula would be
=IF(A1="","","There is value in cell "&CELL("address",A1))
P.S You can additionally use one of the four values as the last parameter in the first formula.
Does this do the trick:
=IF(A1<>"","There is a value in cell "&CHAR(64+COLUMN(A1))&ROW(A1),"")
You can also use ADDRESS():
=IF(A1<>"","There is a value in cell "&ADDRESS(ROW(A1),COLUMN(A1),4))
It takes row and column as arguments with optional argument for return type, that is set to relative in this example.
How can I get the value of the cell in column C row 24-A1, where A1 is the cell A1.
For example, if the value in cell A1 is 4, I want to get the value of cell C20 as the row number is 24 - 4 = 20.
The following fails with a #NAME? error:
=C$(24-A1)
You are looking for the INDIRECT function
=INDIRECT("C"&(24-A1))
You can do this with the OFFSET function
=OFFSET(C24,-A1,0)
This will take the location of cell C24, subtract A1 from the row reference, and add 0 to the column reference.