Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Return All Sheets to Cell A1 before save

Hi

I have a workbook which comprises 11 worksheets. Before saving the workbook,
I would like to return all sheets to cell A1 except for two worksheets - one
called "Database-address" and the other "Database - Name" which asre to be
returned to cells A4 and A6 respectively.

How can I do this with vba code.

Thanks

Darryl


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Return All Sheets to Cell A1 before save

Darryl
Place this macro in the ThisWorkbook module. Note that you have to have
2 sheets named exactly as they are named in this macro, spaces and all. HTH
Otto

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Select
If ws.Name < "Database-address" And ws.Name < "Database - Name"
Then
Range("A1").Select
Else
If ws.Name = "Database-address" Then Range("A4").Select
If ws.Name = "Database - Name" Then Range("A6").Select
End If
Next ws
End Sub

"Darryl" wrote in message
...
Hi

I have a workbook which comprises 11 worksheets. Before saving the
workbook, I would like to return all sheets to cell A1 except for two
worksheets - one called "Database-address" and the other "Database - Name"
which asre to be returned to cells A4 and A6 respectively.

How can I do this with vba code.

Thanks

Darryl


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Return All Sheets to Cell A1 before save

Put this in the ThisWorkbook module and change sheet names and range to
suit.

Private Sub Workbook_BeforeSave _
(ByVal SaveAsUI As Boolean, Cancel As Boolean)
sheets.Select
Range("a1").Select
Application.Goto sheets("sheet2").Range("a6")
Application.Goto sheets("sheet3").Range("a8")
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Darryl" wrote in message
...
Hi

I have a workbook which comprises 11 worksheets. Before saving the
workbook, I would like to return all sheets to cell A1 except for two
worksheets - one called "Database-address" and the other "Database - Name"
which asre to be returned to cells A4 and A6 respectively.

How can I do this with vba code.

Thanks

Darryl



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
return same cell value from numerous sheets Laurie Excel Worksheet Functions 5 April 11th 08 02:19 PM
Return a blank cell instead of a zero value for two linked sheets. Matt Excel Discussion (Misc queries) 1 February 4th 07 02:37 AM
Save a cell location and return to it Adam[_12_] Excel Programming 7 January 17th 06 08:41 AM
Return all sheets to cell A1 glenlee Excel Discussion (Misc queries) 4 September 25th 05 01:03 PM
Macro to loop thru sheets & return to a1 cell CassieM Excel Programming 5 April 21st 05 04:35 PM


All times are GMT +1. The time now is 07:39 PM.

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"