ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Moving Worksheets using VB (https://www.excelbanter.com/excel-discussion-misc-queries/126595-moving-worksheets-using-vbulletin.html)

Marie Bayes

Moving Worksheets using VB
 
Hi
I have the following code (created by setting up a macro):
Sheets.Add
ActiveSheet.Select
ActiveSheet.Move After:=Sheets(4)
ActiveSheet.Select
ActiveSheet.Name = "Feb Daily"
But I would like the Activesheet.move to always move the selected tab to the
'end' as when I run this macro I don't know how many worksheets I will have.
Is there any code that will tell it to do that?
Thanks in advance.

Mike

Moving Worksheets using VB
 
try this

Sub movesheet()
ActiveSheet.Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets .Count)
End Sub


"Marie Bayes" wrote:

Hi
I have the following code (created by setting up a macro):
Sheets.Add
ActiveSheet.Select
ActiveSheet.Move After:=Sheets(4)
ActiveSheet.Select
ActiveSheet.Name = "Feb Daily"
But I would like the Activesheet.move to always move the selected tab to the
'end' as when I run this macro I don't know how many worksheets I will have.
Is there any code that will tell it to do that?
Thanks in advance.


Mike

Moving Worksheets using VB
 
Sub movesheet()
ActiveSheet.Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets .Count)
End Sub

"Marie Bayes" wrote:

Hi
I have the following code (created by setting up a macro):
Sheets.Add
ActiveSheet.Select
ActiveSheet.Move After:=Sheets(4)
ActiveSheet.Select
ActiveSheet.Name = "Feb Daily"
But I would like the Activesheet.move to always move the selected tab to the
'end' as when I run this macro I don't know how many worksheets I will have.
Is there any code that will tell it to do that?
Thanks in advance.


Marie Bayes

Moving Worksheets using VB
 
Perfect, thanks.

"Mike" wrote:

Sub movesheet()
ActiveSheet.Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets .Count)
End Sub

"Marie Bayes" wrote:

Hi
I have the following code (created by setting up a macro):
Sheets.Add
ActiveSheet.Select
ActiveSheet.Move After:=Sheets(4)
ActiveSheet.Select
ActiveSheet.Name = "Feb Daily"
But I would like the Activesheet.move to always move the selected tab to the
'end' as when I run this macro I don't know how many worksheets I will have.
Is there any code that will tell it to do that?
Thanks in advance.


Don Guillett

Moving Worksheets using VB
 
Sub movenameactivesheet)
With ActiveSheet
.Name = "Don"
.Move After:=Sheets(Sheets.Count)
End With
End Sub
--
Don Guillett
SalesAid Software

"Marie Bayes" wrote in message
...
Hi
I have the following code (created by setting up a macro):
Sheets.Add
ActiveSheet.Select
ActiveSheet.Move After:=Sheets(4)
ActiveSheet.Select
ActiveSheet.Name = "Feb Daily"
But I would like the Activesheet.move to always move the selected tab to
the
'end' as when I run this macro I don't know how many worksheets I will
have.
Is there any code that will tell it to do that?
Thanks in advance.





All times are GMT +1. The time now is 05:40 PM.

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