I'm sorry if I put this question in the wrong section, because it is not entirely focussed on programming. But I don't know where to put it else.
I have the following rule as data validation for a particular cell in Excel:
=INDIRECT($D$5)
I want to copy this data validation rule to other cells. However, when I copy/paste the cell, it literally pastes the value of the data validation instead of the relative data validation. So I want $D$5 to be $D$6, $D$7 etc. in other cells. I have tried Paste Special > Validation, but it didn't work. Maybe there is a script for this?
Thanks.
Thanks to #doug-glancy comment and to make sure there is an answer for this question, writing a formula as =INDIRECT(D5) does the job.
In my case I set the formula and by drag and drop copying the cell formulas of new cells will automatically get updated.
Related
I am trying to do a comparison/Conditional Formatting between columns based on a drop-down choice. I have a formula that works fine in the spreadsheet, but does not seem to be working in my Conditional Formatting formula. Is INDIRECT causing my issue?
Formula is:
=IF(H1>100, IF((H1-INDIRECT(ADDRESS(ROW(H1), MATCH($H$4,$A$3:$I$3,0))))/((H1+INDIRECT(ADDRESS(ROW(H1), MATCH($H$4,$A$3:$I$3,0))))/2)>$J$2,TRUE,FALSE),FALSE)
Kind of hard to read, but the part that broke it is trying to grab my comparison cell using the following:
INDIRECT(ADDRESS(ROW(H1), MATCH($H$4,$A$3:$I$3,0)))
Where $H$4 is my drop-down value. So I am selecting the column that contains the data I want to compare to, then using address to select the current rows cell, then accessing it with INDIRECT.
If I replace the INDIRECT part with an actual cell, everything works as it should as well.
When I use the first formula, everything looks great if I input it into a cell on the worksheet, but I would rather not dirty it up if I don't have to. Is there a way to make this work?
My first post here, maybe someone will be able to help.
I have a large Excel table with data from labs. Some results are below LOD And I need to remove them as I do not need them.
So basically I need to clear data in one cell, say E11, if data in D11 shows "<". Meaning below LOD.
If possible I would like to replace value in E11 with "-".
Is there any one who could help me please.
There are a few ways to go about this and you don't really need VBA.
Without VBA - Create a filter on your results and simply filter away the "<" - you could copy and paste this filtered table to another sheet
You could use a cell formula to help you identify results: =IF(A1="<","",B1) which would look at A1, if A1 was a < then it'd return nothing, otherwise it'll return value in cell B1.
With VBA - you'd basically be applying the same logic, just written in code. If you really want to do this, then look up how to do a loop first and how to use IF logic...
enter image description here
This is the worksheet I work with. I would like to clear all the values where < is next to them. This is just part of much bigger table.
I am sure this is really simple but cannot get it to work. I am trying to do some conditional formatting on a sheet that over time will have additional columns added to it. I want the formatting to be there before hand since the data is being added via VBA and the person using the spreadsheet are not Excel experts.
What I have is a column with numbers in. When a new column is entered I want to compare the value with the value in the previous column and then colour the cell accordingly. I can do this for a single cell with for example "=D2>C2".
I want to be able to write the rules in cell D2 comparing it with cell C2 and then have the rules apply across the area D2:DDD300. So for example cell N19 will compare itself to cell M19.
I thought I could use the "Applies to" box but that does not work. Any ideas on how I can achieve this?
Okay this now appears to be working. Not sure what I did differently but deleted all the rules and then set them up again. The only thing I did different was to initially do it for just the 1 cell, then expanded it out to the row when I knew it was working, then finally the whole area.
Sorry to have wasted peoples time
Your method should work. It does for me. Maybe this helps:
I want to change the formatting of a cell if the cell is not valid. In this case, "valid" means that the cell has failed the data validation rules.
I'm asking this question because I couldn't find the answer on SO. I eventually solved it. I'll post my answer and see if people want to comment or provide a better answer!
Here's a basic outline that I want to turn into a better formatted answer later this week when I have more time.
Create a Data Validation rule. In my case, I referenced a list of data in another workbook.
Turn off the alert for invalid data, we'll use the conditional formatting to show the data is invalid.
Add a conditional formatting option for the cells that have the data validation rule. To do this, go to Manage Rules -> New Rule, and in the formula, use =IS_VALID(CELL("row",C4), CELL("col", C4)), where C4 is the first cell you want to start entering data into.
Create a custom function that looks something like
this:
Public Function IS_VALID(row, column) As Boolean
IS_VALID = Not Cells(row, column).Validation.value
End Function
Finally, you can set your conditional formatting effects to whatever you want, like coloring the cell red. This answer worked for me, and I wanted to not forget to add it to SO, but don't have the time to make it all pretty right now.
If you are referencing a list in another workbook, then it is simpler to recreate the data validation rule as a conditional formatting rule.
If your conditional formatting starts at Cell A1 on Sheet1, and the list is contained from A1:A10 on Sheet2, then your conditional formatting rule would be:
=AND($A1<>0,COUNTIF(Sheet2!$A$1:$A$10,$A1)<1)
This would highlight the cell if its value does not appear in the source list, and is not blank.
Clearly, for non-list based data validation, you can come up with an equivalent formula in the same manner.
You could make things more robust by setting up a named range for the list which both the data validation and conditional formatting refer to, such that if the list range grows, you only need to edit it in one place (the Name Manager), and it will update both Data Validation and Conditional Formatting ranges.
What I'm doing is a simple map on one tab of an office space that has all the cubicals laid out. On this map, I have conditional formatting checking another table of listen computers for the last time they were updated/maintained. It works as it stands, but we are moving into a new building and the map (which is already done) has WAY more cubes than last time. So I'm trying to figure out a more efficient way to do this task.
Here is the code:
=AND(VLOOKUP("CCA C1",LOCATION,3,FALSE)<>"",VLOOKUP("CCA C1",LOCATION,3,FALSE)<TODAY()-80)
So as it sits, it works fine. But what I'm trying to do is change the "CCA C1" to simply read the contents of the cell it's formatting so I can just format an entire range of cells rather than doing it cell by cell. The "CCA C1" is in the location of the second sheet (it's a named range). So this checks that entire range for "CCA C1" and checks if the date a couple columns over in that row is within 80 days, if it's not it highlights the cell in the map in red reminding us we need to check the computer. But what I would like to do is simply put "CCA C1" in the cell in the map (which is already is labeled), and have this check for the value of the cell it's formatting and look for that value the same way it's looking now. Just without me having to put "CCA C1" in the formula, I'd like to say something like this:
=AND(VLOOKUP(CURRENT CELL VALUE,LOCATION,3,FALSE)<>"",VLOOKUP(CURRENT CELL VALUE,LOCATION,3,FALSE)<TODAY()-80)
Make sense? Anyone know of a way to do this? Otherwise I have to conditionally format each individual cell with the value manually rather than just format all the cells with the same formatting and have the formula check the contents of the cell for what to look for in the location range of the other sheet.
And to clarify, I know that I can put in the actual cell, such as E3, but then I still have to manually change the formula for each cell which defeats the purpose. I want to just say current cell or something like that. I have 3 conditional formats for each cell, I have around 100 cells to be formatted, so rather than having 300 formats I have to put in, I'd love to just do 3. Not sure if this is possible, that's why I'm asking :)
Just replace "CCA C1" with the address of the first cell in the range of cells with the conditional formatting. Assuming your conditional formatting starts in B2:
=AND(VLOOKUP(B2,LOCATION,3,FALSE)<>"",VLOOKUP("CCA C1",LOCATION,3,FALSE)<TODAY()-80)
EDIT: As I commented, I'm not sure I understand the issue, but if I do, you need to enter the range of cells with CF in the applies to range of the CF dialog, rather than copying and using Paste Special:
Note that this works with the merged cells.
You will need to adjust the applies to range as you add more computers, etc., but the same formula will work.