View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Jonas Jonas is offline
external usenet poster
 
Posts: 16
Default Checkboxes disappear after macro is run

Hi, been traveling but now back to solve this...

My check boxes are located on separate rows. About 20 of them on each sheet.
Your code hides and shows rows but not all rows. Very strange.
Referencing with a public variable - how do you mean?

/J

"JLGWhiz" wrote:

Maybe I still don't understand the problem.

I used a single checkbox on a
sheet and ran your macros. The first macro hid two rows, the the second
macro, as modified, unhid them. I have now tried it with two checkboxes and
it worked OK. Maybe it has to do with where the checkboxes are located. Are
any on the same row? Have you tried using a different reference from the
TopLeftCell? Like a public variable?

"Jonas" wrote:

"JLGWhiz" wrote:

I looked at your post again, and see that I misread the problem. I think
maybe this modified version of your second macro might cure the problem.

Sub restore_from_print()

Dim obj As OLEObject

Application.ScreenUpdating = False

For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CheckBox Then
If obj.Object.Value = False Then
ActiveSheet.Rows(obj.TopLeftCell.Row - 2).EntireRow.Hidden =
False
ActiveSheet.Rows(obj.TopLeftCell.Row - 1).EntireRow.Hidden =
False
obj.Visible = True
End If
End If

Next obj

Application.ScreenUpdating = True

End Sub

'When the row is hidden, the top left relative cell reference changes.


Hmm, I get it but your suggestion won't do the trick.
The row references seem to get messed up somewhere.
Any other ideas?

Regards Jonas