ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CheckBox question (https://www.excelbanter.com/excel-programming/333343-checkbox-question.html)

Frank Rudd via OfficeKB.com

CheckBox question
 
I put this in the general Excel section, but I think it should probably go
here instead.

I am updating a very old spreadsheet that I've put 55 check boxes on with the
intent that when they are checked and a command button clicked only the pages
selected will print. These pages are already set up on the next sheet (it
used to be 55 separate sheets, but I've combined these into one), and the
page breaks have been set so each will print correctly. I've also put a check
box that I've labeled "select all" and print command button so we only print
what's needed.

Silly me, I thought I could figure this out, but the only thing I can come up
with that works is to write 55 separate macros, changing the check boxes to
command buttons, and another macro that simply clicked each button. This
seems to be very inefficient, and I was hoping someone could help me with
this. I would very much appreciate it.

--
Message posted via http://www.officekb.com

STEVE BELL

CheckBox question
 
First I would remove the check boxes and put this code in the sheet module.
Each time you select a cell in column A it will either enter an X or remove
the X.
(change 1 to any number to change the column A=1, B=2, C=3.....)
(This also allows you to make the list shorter or longer without adding
code.)

Place the second code in a standard module. It will search column A for an
X and do
whatever you want...
=================================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False

If Target.Column = 1 And Len(Target) = 0 Then
Target = "X"
Else
Target.ClearContents
End If

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub
===================================
Sub DoMyThing()
Dim x As Long, lrw As Long

Application.ScreenUpdating = False
Application.EnableEvents = False

lrw = Cells(Rows.Count, "A").End(xlUp).Row

For x = 1 To lrw
If Len(Cells(x, 1)) 0 Then
' [put your code here]
End If
Next

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub
=================================

--
steveB

Remove "AYN" from email to respond
"Frank Rudd via OfficeKB.com" wrote in message
...
I put this in the general Excel section, but I think it should probably go
here instead.

I am updating a very old spreadsheet that I've put 55 check boxes on with
the
intent that when they are checked and a command button clicked only the
pages
selected will print. These pages are already set up on the next sheet (it
used to be 55 separate sheets, but I've combined these into one), and the
page breaks have been set so each will print correctly. I've also put a
check
box that I've labeled "select all" and print command button so we only
print
what's needed.

Silly me, I thought I could figure this out, but the only thing I can come
up
with that works is to write 55 separate macros, changing the check boxes
to
command buttons, and another macro that simply clicked each button. This
seems to be very inefficient, and I was hoping someone could help me with
this. I would very much appreciate it.

--
Message posted via http://www.officekb.com




Frank Rudd via OfficeKB.com

CheckBox question
 
I've tried this, and apparently I'm doing something wrong. If I were to put
this is column B I understand that the Target.Column = 2. What does "Len"
mean? When I try to debug the error, this is the line it stops on.

--
Message posted via http://www.officekb.com


All times are GMT +1. The time now is 12:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com