Data validation excel offset of current cell for two columns SNR and REG - vba

I am trying to with data validation in excel to get two columns in one column so to speak. In the column I have circled blue I want to have the user pick Reg or SNR (circled red) and it will get the offset of the current cell. I have tried [![=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,5)][1]][1] which works as the cell is always 5 to right. However it does not get the values under that but only that one cell. It also of course excludes Reg values.
Is what I am after possible in Excel or do I have to do up a new table to incorporate SNR?

create a named range for SNR and REG and use the below as the formula in the data validation rule:
=INDIRECT($O$5)
You can make the named range for REG dynamic like using the below:
=OFFSET($U$6,0,0,COUNTIF($U$6:$U$6000,">"&0),1)
And simply change the range and do the same for SNR

If I understand you correctly, this is what you are trying to do but let me know if this is not what you intended to do.
First, under cell O5, I set up a Data Validation like the pic above so the end user can pick either SNR or Reg.
Second, I used this OFFSET formula inside Data Validation to display the possible values under either column T or U based on the selection on cell O5:
=IF(O5="SNR",OFFSET($T$6,0,0,COUNTIF($T$6:$T$6000,">"&0),1),OFFSET($U$6,0,0,COUNTIF($U$6:$U$6000,">"&0),1))

Related

Naming a dynamic cell range based on another worksheet.

I want to set up a dynamic cell range, which varies length and start point of the range based on user inputs.
I've named a range using the following formula:
=OFFSET(INDIRECT("P"&'FTB data (ML2)'!$N$420),0,0,'FTB data (ML2)'!$N$422,1)
Where:
FTB data (ML2) is the worksheet with the source of data
P is the start column of the data
N420 contains an input for the start row of the range
N422 contains the input for the length of the range
Now this all seems to more or less work, the length varies according to the value in N422 and the start varies based on N420.
The problem is that it's not fixed to the FTB data (ML2) worksheet. I.e when I change tabs to my Summary Sheet, it draws from the range in the summary sheet, no tthe FTB data sheet.
Does anybody have any idea how to make sure it only draws from FTB data, and not the currently active sheet?
Thanks!
I managed to get it working with the following formula:
=OFFSET(INDIRECT("'" & "FTB Data (ML2)" & "'!" & "P"&Summary!$C$1),0,0,'FTB data (ML2)'!$N$422,1)
Turns out you just need a few more ' and " floating about to get an INDIRECT to reference another worksheet correctly.

Count number of times data is repeated in a column and show number in another column?

I have a UserForm that finds and copies a range of data and pastes it along with new data from the UserForm into a different sheet. I am wanting for it to also count the number of times some of that data is repeated in the new sheet. I have tried several different approches but none are working. Right now this is what I have:
.Range("I1").Value = iVal = Application.WorksheetFunction.CountIf(Range("A3:A103"), "CrisisNameTextBox1.Value")
This puts "TRUE" in the corresponding cell instead of the number of times the data is repeated.
You probably could use this function in the corresponding cell:
=COUNTIF( [range], [cell] )
The [range] is the range you want to check (use $ to make sure its value does not change from one cell to another)
The [cell] is the cell you are currently checking.
Assign the function to the cells you want and it should work
If you want to drag/copy this formula from one cell to an other : use the $ character to lock the coordinates you don't want to be changed. I.e :
$A1 Will prevent the column from being changed, but will allow the row
A$1 Will prevent the row from being changed, but will allow the column
$A$1 Will prevent both coordinates from being changed
The same applies to ranges ($A1:$F15, $A1:F1, $A$1:F15, A1:$F15, etc.)

How to keep named range formula from changing cell values with VBA

I noticed an interesting problem while trying to debug a VBA routine that sorts the list of worksheets in a range and then redraws the border around that range.
The range containing is defined in Name Manager with the formula as shown below
=Tables!$L$2:$L$22
The problem that is occurring is that while doing the sheet name work, sometimes cells are deleted and sometimes cells are inserted. This CHANGES the cell address values in the named range. So if I deleted two cells and inserted one cell, the formula changes to
=Tables!$L$2:$L$21
And if I happen to insert into the first cell (L2), then the formula changes to
=Tables!$L$3:$L$22
I'm certain that problem can be solved using the header range name and offsetting by one, but I'm not sure how to do that in the formula for a named range as I've tried numerous ways and can't get it right. But I also need the ending range address to be static.
Any help appreciated.
One thing to try is to use:
=Indirect("Tables!$L$2:$L$22")
rather than
=Tables!$L$2:$L$22
It is an acceptable Name, but I am not sure you will get the same functionality.
Found a better way than the comment using the static header range. You simply define the whole range using the offset function from the header.
=OFFSET(AllSheetsHeader,1,0,21,1)
Where the 1,0,21,1 are 1 row offset from header, 0 column offset, 21 is row height, and 1 is just that one column

get multiple column names (header) in table associated with particular value in to a cell

i need to get multiple column names (header) in table associated with particular value in to a cell
as i explained, i need to get the heading names corresponding to value "n" to column E.
i used the formula
=INDEX((A$1:D$1),MATCH("n",A2:D2,0))
here. but it only give one column name.
i am open to vba scripts also. but i think it doesn't need vba. just improve the the above formula, may be. i tried and failed. any help. thank you guys
if you are really "open" to vba, I'll use one simple UDF like:
Function HeatherNames(rg As Range, rf As String) As String
For Each cell In rg
If cell = rf Then HeatherNames = HeatherNames & Cells(1, cell.Column).Value & "-"
Next cell
HeatherNames = Left(HeatherNames, Len(HeatherNames) - 1)
End Function
you can use it in the column E `=HeatherNames(A2:D2;"n") now you can select the arg.1 (range) and type (or referring to another cell) the arg.2
Assuming you have Excel 2010 or later, in E2:
=IF(COLUMNS($A:A)>COUNTIF($A2:$D2,"n"),"",INDEX($1:$1,AGGREGATE(15,6,COLUMN($A2:$D2)/($A2:$D2="n"),COLUMNS($A:A))))
Copy to the right and down as required.
It would actually be slightly more efficient (and certainly if your dataset in reality is quite large) to have the initial IF clause held within its own cell, such that it is calculated for each row only once, rather than for each instance of the formula within that row. So a better set-up would be, in E2:
=COUNTIF($A2:$D2,"n")
copied down. Then, in F2:
=IF(COLUMNS($A:A)>$E2,"",INDEX($1:$1,AGGREGATE(15,6,COLUMN($A2:$D2)/($A2:$D2="n"),COLUMNS($A:A))))
copied to the right and down again.
Regards

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.