Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default Set Cells to A1 Before Save

I want to have the option to set all cells to A1 before a save (or not set
them before a save).

Here is what I've put together so far from examples.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you want to set all sheets to A1?", vbYesNo)
If a = vbNo Then

(I need a command here to save the workbook and skip the call to SetA1)

SetA1
End Sub


Sub SetA1()
Application.ScreenUpdating = False
For Each ws In Sheets
ws.Activate: ws.Range("A1").Activate
Next
Sheets(1).Activate
Application.ScreenUpdating = True
End Sub


I suspect, however that someone will suggest a better way to do what I want.
I'm all for that !!


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default Set Cells to A1 Before Save

Hi Steve

If user click Yes then run SetA1, else do nothing. Also I would set the
reference to ActiveWorkbook in the 'For Each ws...' statement

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you want to set all sheets to A1?", vbYesNo)
If a = vbYes Then
SetA1
End If
End Sub

Sub SetA1()
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Sheets
ws.Activate
ws.Range("A1").Select
Next
Sheets(1).Activate
Application.ScreenUpdating = True
End Sub

Regards,
Per

"Steve" skrev i meddelelsen
...
I want to have the option to set all cells to A1 before a save (or not set
them before a save).

Here is what I've put together so far from examples.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you want to set all sheets to A1?", vbYesNo)
If a = vbNo Then

(I need a command here to save the workbook and skip the call to SetA1)

SetA1
End Sub


Sub SetA1()
Application.ScreenUpdating = False
For Each ws In Sheets
ws.Activate: ws.Range("A1").Activate
Next
Sheets(1).Activate
Application.ScreenUpdating = True
End Sub


I suspect, however that someone will suggest a better way to do what I
want.
I'm all for that !!



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Set Cells to A1 Before Save

Try the below..

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
If MsgBox("Do you want to set all sheets to A1?", vbYesNo) = vbYes Then
SetA1
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Steve" wrote:

I want to have the option to set all cells to A1 before a save (or not set
them before a save).

Here is what I've put together so far from examples.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you want to set all sheets to A1?", vbYesNo)
If a = vbNo Then

(I need a command here to save the workbook and skip the call to SetA1)

SetA1
End Sub


Sub SetA1()
Application.ScreenUpdating = False
For Each ws In Sheets
ws.Activate: ws.Range("A1").Activate
Next
Sheets(1).Activate
Application.ScreenUpdating = True
End Sub


I suspect, however that someone will suggest a better way to do what I want.
I'm all for that !!


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
save - some cells save but others don't AM Excel Discussion (Misc queries) 4 June 8th 07 01:53 AM
How do I save formatted cells in excel? JayBird Excel Discussion (Misc queries) 1 March 10th 06 08:24 PM
CTRL +S highlights cells, won't save Dbk Excel Discussion (Misc queries) 3 February 16th 06 08:02 PM
Save As .XML, not exporting blank cells roblo Excel Discussion (Misc queries) 2 January 4th 06 03:09 PM
cells not right when save as html Scott Excel Discussion (Misc queries) 0 February 23rd 05 01:59 PM


All times are GMT +1. The time now is 08:13 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"