• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need help with Auto Save

Kempfat

New Member
Hello again... man this VBA stuff is killing me! LOL! I have figured out (with the help of Hui) how to unhide a worksheet and have it open automatically. The issue I am having now is that I have added a Command Button (Also with the help of Hui) to close the worksheet and it works great. I just can't figure out how to add the VBA to auto save the work sheet and uncheck the box on sheet 1 when the worksheet is rehidden.


This is what I have for my Command Buttons:

[pre]
Code:
Private Sub CommandButton2_Click()

Worksheets("Room 102").Visible = False
End Sub
(I would love to add the Auto Save here if possible as well as auto uncheck the box when the sheet is hidden again)


This is what I have for unhiding the worksheets:

Sub CheckBox29_Click()

If Sheet1.DrawingObjects("Check box 29").Value > 0 Then
Worksheets("Room 101").Visible = True
Worksheets("Room 101").Select
Else
Worksheets("Room 101").Visible = False
End If

End Sub
[/pre]
Any help would be greatly appreciated!
 
Do you mean

[pre]
Code:
Private Sub CommandButton2_Click()
Worksheets("Room 102").Visible = False
Sheet1.DrawingObjects("Check box 29").Value=False
End Sub

and 

Sub CheckBox29_Click()

If Sheet1.DrawingObjects("Check box 29").Value > 0 Then
Worksheets("Room 101").Visible = True
Worksheets("Room 101").Select
ActiveWorkbook.Save
Else
Worksheets("Room 101").Visible = False
End If

End Sub
[/pre]
 
Hui... Thanks again! The saving VBA is very close. Instead of saving upon unhiding the worksheet, I would like to save when the worksheet is hidden. I tried to change the ActiveWorkbook.Save to InactiveWorksheet.Save but it did not work... Any ideas?

This is what you gave me:

[pre]
Code:
Sub CheckBox29_Click()

If Sheet1.DrawingObjects("Check box 29").Value > 0 Then
Worksheets("Room 101").Visible = True
Worksheets("Room 101").Select
ActiveWorkbook.Save
Else
Worksheets("Room 101").Visible = False
End If

End Sub

This is what I did:

Sub CheckBox29_Click()

If Sheet1.DrawingObjects("Check box 29").Value > 0 Then
Worksheets("Room 101").Visible = True
Worksheets("Room 101").Select
InactiveWorksheet.Save
Else
Worksheets("Room 101").Visible = False
End If

End Sub
[/pre]
 
So it should be

[pre]
Code:
Sub CheckBox29_Click()

If Sheet1.DrawingObjects("Check box 29").Value > 0 Then
Worksheets("Room 101").Visible = True
Worksheets("Room 101").Select
Else
Worksheets("Room 101").Visible = False
ActiveWorkbook.Save
End If

End Sub
[/pre]
 
Hey Hui! Again... Thank you for your assistance! The code that you gave me to save upon hiding a worksheet didn't seem to work. However, I was able to add it to my command button and it works like a charm. Here is what you suggested:


If Sheet1.DrawingObjects("Check box 29").Value > 0 Then

Worksheets("Room 101").Visible = True

Worksheets("Room 101").Select

Else

Worksheets("Room 101").Visible = False

ActiveWorkbook.Save

End If


End Sub


Here is what I have done:


Private Sub CommandButton1_Click()

Worksheets("Room 101").Visible = False

Sheet1.DrawingObjects("Check box 29").Value = False

ActiveWorkbook.Save

End Sub


Thanks again Hui... I would not have been able to figure it out without you!
 
Back
Top