Use MACROS to highlight a cell when any one checkbox is checked (multiple checkboxes, one cell) - vba

I'm a real newbie with excel (and coding).  I've figure out, using Conditional Formatting, to highlight one cell if the value of another cell changes (based on a checkbox changing).  What I have are multiple cells with checkboxes (cannot be ActiveX checboxes since MAC users need to be able to run it), if any one of those checkboxes are checked, another cell has to be highlighted.
For example, Cells A1, B1, C1, D1, E1 all have check boxes.  If any one of those are checked, cell F1 needs to be highlighted.  I was able to set it up so that if A1 is checked, then cell G1 says "TRUE" then cell F1 highlights.  When I link all the checkboxes to cell G1 and select only B1 - all cells (A1, C1, D1, E1) are checked AND cell F1 is highlighted.  
I need to be able to have one cell highlighted if any one of (or all) A1, B1, C1, D1, and/or E1 is checked. 

You can have each check box link to its own cell, for example A2, B2, C2, D2, E2. Then use a formula in G1
=COUNTIF(A2:E2,TRUE)
Use G1 as the input for your conditional format. If no box is checked it will be 0, if any box is checked it will be greater than 0.
Edit after comment: If you use hundreds of check boxes in the spreadsheet grid, then you're not using Excel efficiently. Check boxes are form controls, which means they are good for using in forms. In the grid they are best used sparingly, for exactly the issues that you are encountering.
Consider using cell values instead of check boxes. Format the cells with the Marlett font and type an "a" or a "b" to produce a check mark in the cell. Then you can use a Countif($A2:$F2,"a") as the input for your conditional formatting.

Related

Is there an excel formula like INDIRECT to get a dependent drop down from another workbook?

How can I get dependent dropdown in cell D2 based on dropdown value chosen in cell C2 in Workbook1 from Workbook2? The INDIRECT method seems to work for different sheets in the same workbook. Couldn't find a method that worked for different workbooks.
Example -
C2 value - Services, D2 should load - Third party service, and so on
C2 value - Medical Devices, D2 should load - Dosimetry and so on.
These values are in Workbook2. I successfully loaded values in C2 but can't load dependent values in D2. How can I load the dependent values?
I'm not sure why you feel that you need INDIRECT but I just got an example working without it.
(INDIRECT should generally be avoided for a number of reasons.)
test.xlsm :
A1:A5 populated with A,B,C,D,E
Drop Down 1:
Input Range: $A$1:$A$5
Cell Link: [Book2]Sheet1!$A$1
book2.xlsm :
A1 = cell link
Drop Down 1:
Input Range: [test.xlsm]Sheet1!$A$1:$A$5
Cell Link: $A$1

VBA to jump to certain cell after changing contents of one

I am creating a spreadsheet that I want to force people to input certain information. Is there anyway of forcing people when changing the contents of a cell that once return or tab is entered that it jumps to another cell.
For Instance:
CELL C2 (Date) 01/01/2001
CELL C4 (EMPTY) JUMP HERE
So above I want someone to enter a date in C1 and when they change this is jumps to C3.
Kris
The selection of a specific cell in the first sheet:
ThisWorkbook.Sheets(1).Range("A2").Select
You can use name of the sheet as a string instead of 1 in sheets(1)

Writing a cell in Excel

This query might seem a bit childish, but this has been bugging me for quite a few days.
I am completely new to Microsoft Excel and want to know how do hold same values in two different excel cells?
Example: Cell A1=bandwidth Cell E1=[minimum:bandwidth():utilization]
I want the word "bandwidth" to be same in both the cells. So if the user
inputs "bandwidth" into cell A1, then this generated into E1.
Kindly help me with this one.
In E1 enter the formula:
="minimum:" & A1 & "():utilization"
as you update A1, the displayed text in E1 will follow.
Adding to the solutions already given, you can define the format to be used for A1 with the TEXT function:
="minimum:" & TEXT(A1,"#,##0.00") & "():utilization"

vlookup not finding vba cells

I have a table that uses a bit of vba to populate column b with id numbers.
I then have column c as a vlookup that gets a name based off the id, from another sheet. The vlookup in the first cell works fine and returns the correct name, John Doe.
When I drag down, the rest of the cells in column c return the same name as the first, John Doe. The vlookup in the other cells is exactly the same, except the reference cell does change, as expected....so, c2 = vlookup(b2, $range, col, false), c3= vlookup(b3..), c4=vlookup(b4,..), etc.
The catch is, when I look at the vlookup in c3 and click on b3, the cell changes to find the correct name (no longer John Doe). So it works fine. And I have to do that for every cell in column c.
It's like vlookup isn't aware that column b changed? Is that something that happens with vba? Is there a refresh command or some other way for vlookup to register that column b has changed without having to click on each individual vlookup function?
If you've entered a formula in a cell, then copied the formula to another cell and Excel hasn't updated your results, that means that Calculation Mode is Manual.
To fix it (depending on version, this is for Excel 2010)
Click on Formulas in the Ribbon
Click on Calculation Options
Click on Automatic
If you need to have it calculate manually (valuable for making many formula changes in a large worksheet):
Click on Formulas in the Ribbon
Click on Calculate Now to calculate the entire workbook, or
Click on Calculate Sheet to calculate the current worksheet
You can skip all the clicking by pressing F9 to Calculate Now or Shift-F9 to Calculate Sheet.

Working with merge and center cells in Excel using VBA

If I take a range over merge and centered cells in excel, are each of them addressed as single cells or the group of cells constituting them? For example, if the cells A1 to A10 are merged and I do a
Worksheets(1).Range("A5")
Would this return the range of a single cell among those constituting the merged cell or a range consisting the merged cell itself? And what value would it contain if I get its value?
In other words, how would you represent range over merged cells in excel VBA?
Also, how can I get the range of the non merged cells adjacent to the length of this merged cell?
In other words, how would you represent range over merged cells in excel VBA?
By addressing it with the top left cell. Ex: "A1" in this case.
When in doubt, check it yourself first. If still in doubt, search google or whatever search engine you use. Still if something is unclear, ask :)
Would this return the range of a single cell among those constituting the merged cell or a range consisting the merged cell itself? And what value would it contain if I get its value?
It would return a single cell A5 which doesn't have anything in it because when you merge cells the data from the top left cell is kept and rest discarded. The reason why I say discarded is that if you now unmerge the cells, you will not get your values back.
Best way to check:
Let's say A1 to A10 had 1,2,3..10. Merge them. The cell will now have only 1
Try this in Immediate window
?Range("A5").Value
You will get nothing. Similarly if you want to write to it, you cannot use Range("A5").Value = "Blah". You have to address it with the top left cell. For example
Range("A1").Value = "Blah"