View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Pete Rooney Pete Rooney is offline
external usenet poster
 
Posts: 56
Default Creating a Macro? V2

Hi, Lynda,

I read your mail again.

Open your workbook and hit Alt-F11 to go into the VB editor.

In the VBA Project window (top left), double click on "ThisWorkbook" and
enter the following:

Private Sub Workbook_Open()
sheets("Sheet 1").activate
End Sub

then do Alt-F11 again and save your workbook.

Sheet 1 will be made the active workbook whenever you open the workbook
subsequently.

Regards

Pete




"Lynda" wrote:

I don't know how to reply to a post and get it to come back to the top of the
list so I am starting a new thread under the same heading. Sorry everyone.
Pete and Gord responded to my original thread but unfortunately I was not
able to get their advice to work. My original question related to a four page
survey. The survey
is posted on our intranet at work for people exiting our employment. Once
they have completed the survey they activate the submit button returning the
survey to our HR people.
The survey contains four pages (worksheets) with the submit button on the
last page (page four). When the submit button is activated it emails the
workbook. When the recipients opens the workbook it opens at page four
because that was the last page open and the one with the submit button on it.
I want the macro to basically return the workbook to page one when the
submit button is activated so that when the recipients open the workbook they
see page one first and not page four.

The VBE I am using is below and is one of Debras (I just wish I knew how to
write this stuff, but I am learning a little bit, obviously not enough though)

Sub Mail_workbook_1()

Dim wb As Workbook
Set wb = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation


Exit Sub
End If
End If

On Error Resume Next
wb.SendMail Array("email.address"), _
"Exit Survey"
On Error GoTo 0
End Sub

Sorry this is so long.

Cheers