View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default How to return to sheet I came from?

Thanks Charles (nice name)
Thanks very much for both suggestions. I appreciate your more efficient
version, but doubly so you taking the time to support my feeble code. You're
a Gentleman and a Scholar.

Vaya con Dios,
Chuck, CABGx3



"Charles Chickering" wrote:

In answer to your question you can get the ActiveSheet Name before you leave
then go back when your done.
Sub OpenLog()
Dim ws As Object
Dim k
Set ws = ActiveSheet
k = ActiveWorkbook.BuiltinDocumentProperties.Item("Aut hor")
Worksheets("Openlog").Visible = True
Worksheets("Openlog").Select
Range("OpenLog!a65000").Select
Selection.End(xlUp).Select
Selection.Offset(1, 0).Select
Selection.Value = Date & ", " & Time
Selection.Offset(0, 1).Select
Selection.Value = k
Worksheets("Openlog").Visible = False
ws.Activate
End Sub

However... I wouldn't even bother activating the other sheet. Try this
instead, it should run quicker:
Sub OpenLog()
Dim k
Dim r As Range
k = ActiveWorkbook.BuiltinDocumentProperties.Item("Aut hor")
With Worksheets("Openlog")
Set r = .Range("A" & .Rows.Count).End(xlUp)
End With
r.Offset(1) = Date & ", " & Time
r.Offset(1,1) = k
End Sub

--
Charles Chickering

"A good example is twice the value of good advice."


"CLR" wrote:

Hi All.......
Small macro writes to bottom of list on hidden sheet....works fine, except I
don't know how to return to the sheet I started from.....it just wants to
return me to a sheet next to the freshly hidden one. I do not know the name
of the starting sheet, so cannot hard code it in.

Sub OpenLog()
Dim k
k = ActiveWorkbook.BuiltinDocumentProperties.Item("Aut hor")
Worksheets("Openlog").Visible = True
Worksheets("Openlog").Select
Range("OpenLog!a65000").Select
Selection.End(xlUp).Select
Selection.Offset(1, 0).Select
Selection.Value = Date & ", " & Time
Selection.Offset(0, 1).Select
Selection.Value = k
Worksheets("Openlog").Visible = False
End Sub

Any help would be much appreciated.
Vaya con Dios,
Chuck, CABGx3