ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I need a Macro for Sorting workshhets (https://www.excelbanter.com/excel-programming/371248-i-need-macro-sorting-workshhets.html)

Tanisha

I need a Macro for Sorting workshhets
 
Hello Everyone,
Can some one please assist me in writing a code to move one "named"
worksheet to the begining of a workbook and I would like for this Macro to
Auto Run when the workbook is closed?

Bob Phillips

I need a Macro for Sorting workshhets
 
Try this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Sheet1").Move Befo=.Worksheets(1)
.Save
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tanisha" wrote in message
...
Hello Everyone,
Can some one please assist me in writing a code to move one "named"
worksheet to the begining of a workbook and I would like for this Macro to
Auto Run when the workbook is closed?




Tanisha

I need a Macro for Sorting workshhets
 
I Tried this. It didnt work...I dont know what I am doing wrong
this what I inputed:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Solution Direct Tracking").Move Befo=.Worksheets(1)
.Save
End With
End Sub

Tanisha

"Bob Phillips" wrote:

Try this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Sheet1").Move Befo=.Worksheets(1)
.Save
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tanisha" wrote in message
...
Hello Everyone,
Can some one please assist me in writing a code to move one "named"
worksheet to the begining of a workbook and I would like for this Macro to
Auto Run when the workbook is closed?





Bob Phillips

I need a Macro for Sorting workshhets
 
Did you put it where directed?

What did you get?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tanisha" wrote in message
...
I Tried this. It didnt work...I dont know what I am doing wrong
this what I inputed:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Solution Direct Tracking").Move

Befo=.Worksheets(1)
.Save
End With
End Sub

Tanisha

"Bob Phillips" wrote:

Try this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Sheet1").Move Befo=.Worksheets(1)
.Save
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tanisha" wrote in message
...
Hello Everyone,
Can some one please assist me in writing a code to move one "named"
worksheet to the begining of a workbook and I would like for this

Macro to
Auto Run when the workbook is closed?







Tanisha

I need a Macro for Sorting workshhets
 
Bob ...Thanks for all your help....I figured out my mistake......IT WORKS!
Thanks again


"Bob Phillips" wrote:

Did you put it where directed?

What did you get?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tanisha" wrote in message
...
I Tried this. It didnt work...I dont know what I am doing wrong
this what I inputed:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Solution Direct Tracking").Move

Befo=.Worksheets(1)
.Save
End With
End Sub

Tanisha

"Bob Phillips" wrote:

Try this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Sheet1").Move Befo=.Worksheets(1)
.Save
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tanisha" wrote in message
...
Hello Everyone,
Can some one please assist me in writing a code to move one "named"
worksheet to the begining of a workbook and I would like for this

Macro to
Auto Run when the workbook is closed?







Dave Peterson

I need a Macro for Sorting workshhets
 
I think I would put this kind of code into the workbook_open event.

If someone opens the workbook, makes drastic changes, then tries to close, your
code will Save the workbook.

This may not be what the user intended.

If you put this kind of code in the workbook_open event, that sheet will be
where you want when the user opens the file--and there's no worry about saving
stuff that shouldn't be saved.

Just a thought.

Tanisha wrote:

Hello Everyone,
Can some one please assist me in writing a code to move one "named"
worksheet to the begining of a workbook and I would like for this Macro to
Auto Run when the workbook is closed?


--

Dave Peterson


All times are GMT +1. The time now is 09:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com