Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Return to starting point

Any way that the code below can be made to return me to the worksheet and
cell were the code was triggered?

Sub HolidayRemove()

'Code provided b Mike H

Application.ScreenUpdating = False

On Error GoTo ErrorHandler

For n = 1 To Sheets.Count
If Sheets(n).Name < "Holidays" Then
Sheets(n).Select
Sheets(n).Unprotect
With Sheets(n)
Range("S5").Activate
ActiveSheet.Shapes.SelectAll
Selection.Delete
Range("K1").Value = ""
Sheets(n).Protect
End With
End If
Next n

ErrorHandler:

Application.ScreenUpdating = True

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Return to starting point

We store the sheet & cell and then return the

Sub HolidayRemove()
Dim oldSheet As Worksheet
Dim oldCell As String
Set oldSheet = ActiveSheet
oldCell = ActiveCell.Address
'Code provided b Mike H

Application.ScreenUpdating = False

On Error GoTo ErrorHandler

For n = 1 To Sheets.Count
If Sheets(n).Name < "Holidays" Then
Sheets(n).Select
Sheets(n).Unprotect
With Sheets(n)
Range("S5").Activate
ActiveSheet.Shapes.SelectAll
Selection.Delete
Range("K1").Value = ""
Sheets(n).Protect
End With
End If
Next n

ErrorHandler:

Application.ScreenUpdating = True
oldSheet.Activate
Range(oldCell).Select
End Sub

--
Gary''s Student - gsnu2007k


"Patrick C. Simonds" wrote:

Any way that the code below can be made to return me to the worksheet and
cell were the code was triggered?

Sub HolidayRemove()

'Code provided b Mike H

Application.ScreenUpdating = False

On Error GoTo ErrorHandler

For n = 1 To Sheets.Count
If Sheets(n).Name < "Holidays" Then
Sheets(n).Select
Sheets(n).Unprotect
With Sheets(n)
Range("S5").Activate
ActiveSheet.Shapes.SelectAll
Selection.Delete
Range("K1").Value = ""
Sheets(n).Protect
End With
End If
Next n

ErrorHandler:

Application.ScreenUpdating = True

End Sub



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
Enter doesnt return to the cell below the starting point anymore Jeff Excel Discussion (Misc queries) 3 April 26th 08 02:19 AM
Go back to starting point PeterW[_13_] Excel Programming 2 August 16th 06 01:57 PM
Indexing Values to Same Starting Point for Relative Return Chart Notclevr Charts and Charting in Excel 1 January 18th 06 10:33 PM
bar chart starting point lnoles Charts and Charting in Excel 1 October 14th 05 02:16 PM
Starting Point of macro Turin Excel Programming 1 July 7th 05 12:51 PM


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