run macro on opening

  • Thread starter brian thompson3001 via OfficeKB.com
  • Start date
B

brian thompson3001 via OfficeKB.com

Hi

I have go this off other threads, but would like it to run automatically when
opening the workbook. I am not up to speed with these codes, and therefore
ask if the additional line/lines could be added in the correct place, in
order that I can copy and Paste. Currently, I have to run this every time
after opening the workbook

Option Explicit
Sub auto_open()
With Worksheets("sheet1")
.Protect Password:="test", userinterfaceonly:=True
.EnableAutoFilter = True
End With

End Sub

Can anyone help?,

Brian
 
J

Jonathan West

Hi Brian,

You have posted this to a group that deals with VBA in Word. The Excel
programmers who are more likely to know the answer hang out at
microsoft.public.excel.programming. I suggest you re-post there.
 
M

macropod

Hi Brian,

Wrong NG, but you could try something based on:

Option Explicit

Sub auto_open()
With Worksheets("Sheet1")
Protect Password:="test", userinterfaceonly:=True
.Range("A1","A2").Copy
.Paste Destination:=Range("B1")
EnableAutoFilter = True
End With
End Sub

where:
.. "A1" defines the upper left cell of the range to copy
.. "A2" defines the lower right cell of the range to copy
.. "B1" defines the upper left cell of the destination range

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top