Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
PAS PAS is offline
external usenet poster
 
Posts: 26
Default Check box question???

Is there a way by clicking on a check box, it would do the following to a
particular cell:
1. insert a border
2. insert a data validation list
3. colour the back ground to white

and when unchecked it all disappears untill its checked again.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Check box question???

Record a macro when you do the border, the data|validation and the formatting.

Then record a different macro when you remove what you want.

Then add a checkbox from the Forms toolbar (not the control toolbox toolbar) to
the worksheet.

Then assign this macro to the checkbox.

Option Explicit
Sub TestMe()

Dim CBX As CheckBox

Set CBX = ActiveSheet.CheckBoxes(Application.Caller)

If CBX.Value = xlOn Then
Call AddTheStuff
Else
Call RemoveTheStuff
End If

End Sub

I used AddTheStuff and RemoveTheStuff for the names of the macros in my testing.

You may want to change the recorded macro names to something significant--along
with the macro (TestMe isn't a very good name!).


(for testing only)

Sub AddTheStuff()
MsgBox "Your code to do the work"
End Sub
Sub RemoveTheStuff()
MsgBox "Your code to remove the work"
End Sub

Pas wrote:

Is there a way by clicking on a check box, it would do the following to a
particular cell:
1. insert a border
2. insert a data validation list
3. colour the back ground to white

and when unchecked it all disappears untill its checked again.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
PAS PAS is offline
external usenet poster
 
Posts: 26
Default Check box question???

Thanks Dave
I shall try that.

"Dave Peterson" wrote:

Record a macro when you do the border, the data|validation and the formatting.

Then record a different macro when you remove what you want.

Then add a checkbox from the Forms toolbar (not the control toolbox toolbar) to
the worksheet.

Then assign this macro to the checkbox.

Option Explicit
Sub TestMe()

Dim CBX As CheckBox

Set CBX = ActiveSheet.CheckBoxes(Application.Caller)

If CBX.Value = xlOn Then
Call AddTheStuff
Else
Call RemoveTheStuff
End If

End Sub

I used AddTheStuff and RemoveTheStuff for the names of the macros in my testing.

You may want to change the recorded macro names to something significant--along
with the macro (TestMe isn't a very good name!).


(for testing only)

Sub AddTheStuff()
MsgBox "Your code to do the work"
End Sub
Sub RemoveTheStuff()
MsgBox "Your code to remove the work"
End Sub

Pas wrote:

Is there a way by clicking on a check box, it would do the following to a
particular cell:
1. insert a border
2. insert a data validation list
3. colour the back ground to white

and when unchecked it all disappears untill its checked again.


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.misc
PAS PAS is offline
external usenet poster
 
Posts: 26
Default Check box question???

It works without the validation entry. I will have a go at trying to see
whats wrong and let you know

"Pas" wrote:

Thanks Dave
I shall try that.

"Dave Peterson" wrote:

Record a macro when you do the border, the data|validation and the formatting.

Then record a different macro when you remove what you want.

Then add a checkbox from the Forms toolbar (not the control toolbox toolbar) to
the worksheet.

Then assign this macro to the checkbox.

Option Explicit
Sub TestMe()

Dim CBX As CheckBox

Set CBX = ActiveSheet.CheckBoxes(Application.Caller)

If CBX.Value = xlOn Then
Call AddTheStuff
Else
Call RemoveTheStuff
End If

End Sub

I used AddTheStuff and RemoveTheStuff for the names of the macros in my testing.

You may want to change the recorded macro names to something significant--along
with the macro (TestMe isn't a very good name!).


(for testing only)

Sub AddTheStuff()
MsgBox "Your code to do the work"
End Sub
Sub RemoveTheStuff()
MsgBox "Your code to remove the work"
End Sub

Pas wrote:

Is there a way by clicking on a check box, it would do the following to a
particular cell:
1. insert a border
2. insert a data validation list
3. colour the back ground to white

and when unchecked it all disappears untill its checked again.


--

Dave Peterson
.

  #5   Report Post  
Posted to microsoft.public.excel.misc
PAS PAS is offline
external usenet poster
 
Posts: 26
Default Check box question???

Final code works well and as follows:

Option Explicit

Sub AddTheStuff()
'
' AddTheStuff Macro
' Macro recorded 09/03/2010 by pas.wilts
'
Sheets("Sheet5").Select
Range("F12:H12").Select
ActiveCell.FormulaR1C1 = "Rear Facing Mid"
Range("F13:H13").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=pax1"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Interior.ColorIndex = 2
Sheets("Seats").Select
End Sub
Sub RemoveTheStuff()
'
' RemoveTheStuff Macro
' Macro recorded 09/03/2010 by pas.wilts
'
Sheets("Sheet5").Select
Range("F12:H13").Select
Selection.Interior.ColorIndex = 34
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("F13:H13").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop,
Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
Range("F12:H12").Select
Selection.ClearContents
Range("C10").Select
Sheets("Seats").Select
End Sub

Thank you

"Pas" wrote:

Is there a way by clicking on a check box, it would do the following to a
particular cell:
1. insert a border
2. insert a data validation list
3. colour the back ground to white

and when unchecked it all disappears untill its checked again.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Box Question Ksean Excel Worksheet Functions 5 January 8th 10 02:25 AM
check box question mac Excel Worksheet Functions 3 September 1st 09 12:20 AM
Question regarding VLookup and if it can check two columns of data Smoke Excel Worksheet Functions 2 September 23rd 08 09:10 PM
Check box logic question Ailsa02 Excel Worksheet Functions 4 August 23rd 08 04:04 PM
Question to check the conditions and then print the result. Neelakanta New Users to Excel 1 June 18th 08 08:15 AM


All times are GMT +1. The time now is 10:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"