Dropdown behaviour shows different data depending on selection

TheJay

Active Member
Joined
Nov 12, 2014
Messages
364
Office Version
  1. 2019
Platform
  1. Windows
FIrst of all, apologies for the title, I don't know how to change it and realised I wanted to use a tick box instead of a drop down as I was writing.

I have a spreadsheet which calculates the charge for a date range.
xU4Coxz.png


Now I want to introduce a tick box in C6, which changes whether the inclusive or exclusive end is shown in C7 and relevant data in C8. As well as the data changing, when the tick box is clicked, I'd like the text in C6 to change from 'Exclusive End' to 'Inclusive End'.

The idea is that I don't want anything in row D because I need to incorporate other data eventually in that row. Not sure how this is achieved, can it be done without hidden cells?

The forum wont let me attach the spreadsheet :(
 
Also, I couldn't figure out how the text can change from exclusive to inclusive.
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Probably the empty cells. If you enter valid start and end dates, then it should work.

You need custom format for when the box is unchecked ;;;"Exclusive"
and custom conditional format for when the box is checked ;;;"Inclusive" (see post #5)
 
Upvote 0
Thank you for your reply. I have never worked with conditional formatting before and didn't understand it at all.
 
Upvote 0
Is there a way to make the checkbox invisible until data is entered into one of the cells? I can't see a way of using the usual =IF(ISBLANK(?
 
Upvote 0
You could make the text behind the checkbox invisible with conditional formatting, but hiding the actual checkbox would need vba.

Add a new conditional formatting rule to check if the data cell is empty, i.e. =D1="" (change D1 to the reference of the data cell.
Set the text colour to white (or the same colour as the cell background).
Make sure that this rule is the first in the list and that the 'stop if true' box is ticked.
 
Upvote 0
Thanks for your reply. I like the appearance of the text, which I moved into the column with all the other text.


VBA is the only way to make the checkbox invisible?
 
Upvote 0
VBA is the only way to make the checkbox invisible?
It is, more specifically, you would need a worksheet change event, something like this.
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target.Address(0, 0)
        Case "A1"
            ActiveSheet.Shapes("CheckBox1").Visible = (Len(Target.Value)>0)
        Case "B1"
            ActiveSheet.Shapes("CheckBox2").Visible = (Len(Target.Value)>0)
    End Select
End Sub
The code above shoud hide checkbox 1 when A1 is empty and make it visible when A1 is not empty, then the same for checkbox 2 and B1. More can be added as needed.
Note that the code will not 'correct' the initial state of the checkboxes, if they are already visible while the corresponding cell is empty. In such cases you would need to enter something into the cell, then delete it for the code to be triggered.
 
Upvote 0
Thanks for your reply.

The sheet is called Calculator and the checkbox appears to be called Check Box 1.

VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target.Address(0, 0)
        Case "C7"
            ActiveSheet.Shapes("Check Box1 ").Visible = (Len(Target.Value) > 0)
    End Select
End Sub

At the moment I think I haven't done something correctly as this isn't working. I'm not sure what else I need to add/amend.
 
Upvote 0
I expect that it should be "Check Box 1" not "Check Box1 " (space in the wrong place makes a difference).
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top