Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting Sheets based on checkboxes being unchecked

I have a slight situation that I don't know how to resolve. My IT dept created a userform that prints sheets based on checkboxes that are checked on the userform. The unchecked pages are saved with the checked one's when the file is saved. Is there a way to tell the form to print the checked box (captions) and to delete the unchecked boxs? The checkbox Captions are the names of the actual sheets on the spreadsheet.

For example: If Checkbox "Jeff" is checked, then it would print the sheet "Jeff" but if Checkbox "Mary" is unchecked, then it would delete sheet "Mary" so that it isnt saved.

Any way to do this?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Deleting Sheets based on checkboxes being unchecked

Sorry. Here it is. Thanks for your help.

Dim ctrl As Control
Dim chkbx As MSForms.CheckBox
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
Set chkbx = ctrl
If chkbx Then
Worksheets(chkbx.Caption).PrintOut
End If
End If
Next

"Bernie Deitrick" wrote:

Tip,

It would be easiest if you posted the code that is executed when you press
the commandbutton to do the actual printing. Go into the VBE and double
click on that button within the design view to see the code and copy it to
post here.

HTH,
Bernie
MS Excel MVP

"Tip Top" <Tip wrote in message
...
I have a slight situation that I don't know how to resolve. My IT dept

created a userform that prints sheets based on checkboxes that are checked
on the userform. The unchecked pages are saved with the checked one's when
the file is saved. Is there a way to tell the form to print the checked box
(captions) and to delete the unchecked boxs? The checkbox Captions are the
names of the actual sheets on the spreadsheet.

For example: If Checkbox "Jeff" is checked, then it would print the sheet

"Jeff" but if Checkbox "Mary" is unchecked, then it would delete sheet
"Mary" so that it isnt saved.

Any way to do this?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Deleting Sheets based on checkboxes being unchecked

Tip,

Try this. Change

If chkbx Then
Worksheets(chkbx.Caption).PrintOut
End If

To

If chkbx Then
Worksheets(chkbx.Caption).PrintOut
Else
Application.DisplayAlerts = False
Worksheets(chkbx.Caption).Delete
Application.DisplayAlerts = True
End If

HTH,
Bernie
MS Excel MVP

"Tip Top" wrote in message
...
Sorry. Here it is. Thanks for your help.

Dim ctrl As Control
Dim chkbx As MSForms.CheckBox
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
Set chkbx = ctrl
If chkbx Then
Worksheets(chkbx.Caption).PrintOut
End If
End If
Next

"Bernie Deitrick" wrote:

Tip,

It would be easiest if you posted the code that is executed when you

press
the commandbutton to do the actual printing. Go into the VBE and double
click on that button within the design view to see the code and copy it

to
post here.

HTH,
Bernie
MS Excel MVP

"Tip Top" <Tip wrote in message
...
I have a slight situation that I don't know how to resolve. My IT

dept
created a userform that prints sheets based on checkboxes that are

checked
on the userform. The unchecked pages are saved with the checked one's

when
the file is saved. Is there a way to tell the form to print the checked

box
(captions) and to delete the unchecked boxs? The checkbox Captions are

the
names of the actual sheets on the spreadsheet.

For example: If Checkbox "Jeff" is checked, then it would print the

sheet
"Jeff" but if Checkbox "Mary" is unchecked, then it would delete sheet
"Mary" so that it isnt saved.

Any way to do this?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Deleting Sheets based on checkboxes being unchecked

It returns a Runtime Error 9. Subscript out of string. It looks like it is trying to delete all the sheets including the one's that have the checkboxes checked.

"Bernie Deitrick" wrote:

Tip,

Try this. Change

If chkbx Then
Worksheets(chkbx.Caption).PrintOut
End If

To

If chkbx Then
Worksheets(chkbx.Caption).PrintOut
Else
Application.DisplayAlerts = False
Worksheets(chkbx.Caption).Delete
Application.DisplayAlerts = True
End If

HTH,
Bernie
MS Excel MVP

"Tip Top" wrote in message
...
Sorry. Here it is. Thanks for your help.

Dim ctrl As Control
Dim chkbx As MSForms.CheckBox
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
Set chkbx = ctrl
If chkbx Then
Worksheets(chkbx.Caption).PrintOut
End If
End If
Next

"Bernie Deitrick" wrote:

Tip,

It would be easiest if you posted the code that is executed when you

press
the commandbutton to do the actual printing. Go into the VBE and double
click on that button within the design view to see the code and copy it

to
post here.

HTH,
Bernie
MS Excel MVP

"Tip Top" <Tip wrote in message
...
I have a slight situation that I don't know how to resolve. My IT

dept
created a userform that prints sheets based on checkboxes that are

checked
on the userform. The unchecked pages are saved with the checked one's

when
the file is saved. Is there a way to tell the form to print the checked

box
(captions) and to delete the unchecked boxs? The checkbox Captions are

the
names of the actual sheets on the spreadsheet.

For example: If Checkbox "Jeff" is checked, then it would print the

sheet
"Jeff" but if Checkbox "Mary" is unchecked, then it would delete sheet
"Mary" so that it isnt saved.

Any way to do this?






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
need code for hiding/unhiding sheets using checkboxes pzx8hf Excel Worksheet Functions 1 August 13th 08 12:11 AM
Return value(s) based on selected checkboxes Nikki Excel Worksheet Functions 5 May 7th 07 03:48 PM
Return value based on checkboxes selected -- IF() LOOKUP() William Horton Excel Worksheet Functions 3 April 17th 07 07:56 PM
Return value based on checkboxes selected -- IF() LOOKUP() dq Excel Worksheet Functions 2 April 17th 07 07:48 PM
Sum Based on Checkboxes Vassago Excel Discussion (Misc queries) 6 August 2nd 06 09:15 PM


All times are GMT +1. The time now is 05:25 PM.

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

About Us

"It's about Microsoft Excel"