Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
dan dan is offline
external usenet poster
 
Posts: 866
Default Moving Sheets within a workbook

I have a function that adds a new work when needed

'Add A New Sheet
ActiveWorkbook.Sheets.Add

The problem is that when the sheet is inserted it is placed at the beginning
of the workbook. Sheet2 will appear before Sheet1.

I want to automate the process of moving Sheet2 after Sheet1 and all
subsequent Sheets (3, 4, 5 ...)

Sheets("Sheet2").Select
Sheets("Sheet2").Move After:=Sheets(1)

How do I use a counter/variable in place of the "2" so that each time I call
the "ActiveWorkbook.Sheets.Add" it will add the new Sheet to the end?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default Moving Sheets within a workbook

With ActiveWorkbook.Worksheets
.Add , .Item(.Count)
End With


"Dan" wrote:

I have a function that adds a new work when needed

'Add A New Sheet
ActiveWorkbook.Sheets.Add

The problem is that when the sheet is inserted it is placed at the beginning
of the workbook. Sheet2 will appear before Sheet1.

I want to automate the process of moving Sheet2 after Sheet1 and all
subsequent Sheets (3, 4, 5 ...)

Sheets("Sheet2").Select
Sheets("Sheet2").Move After:=Sheets(1)

How do I use a counter/variable in place of the "2" so that each time I call
the "ActiveWorkbook.Sheets.Add" it will add the new Sheet to the end?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Moving Sheets within a workbook

With ActiveWorkbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
End With


--
HTH

Bob Phillips

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

"Dan" wrote in message
...
I have a function that adds a new work when needed

'Add A New Sheet
ActiveWorkbook.Sheets.Add

The problem is that when the sheet is inserted it is placed at the

beginning
of the workbook. Sheet2 will appear before Sheet1.

I want to automate the process of moving Sheet2 after Sheet1 and all
subsequent Sheets (3, 4, 5 ...)

Sheets("Sheet2").Select
Sheets("Sheet2").Move After:=Sheets(1)

How do I use a counter/variable in place of the "2" so that each time I

call
the "ActiveWorkbook.Sheets.Add" it will add the new Sheet to the end?

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
dan dan is offline
external usenet poster
 
Posts: 866
Default Moving Sheets within a workbook

What I have is if a function is called:

If " some function" Then
ActiveWorkbook.Sheets.Add
End If

Where in the above statement do I insert your statements?

With ActiveWorkbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
End With

Dan


ActiveWorkbook.Sheets.Add


"Bob Phillips" wrote:

With ActiveWorkbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
End With


--
HTH

Bob Phillips

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

"Dan" wrote in message
...
I have a function that adds a new work when needed

'Add A New Sheet
ActiveWorkbook.Sheets.Add

The problem is that when the sheet is inserted it is placed at the

beginning
of the workbook. Sheet2 will appear before Sheet1.

I want to automate the process of moving Sheet2 after Sheet1 and all
subsequent Sheets (3, 4, 5 ...)

Sheets("Sheet2").Select
Sheets("Sheet2").Move After:=Sheets(1)

How do I use a counter/variable in place of the "2" so that each time I

call
the "ActiveWorkbook.Sheets.Add" it will add the new Sheet to the end?

Thanks




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Moving Sheets within a workbook

Instead of this

ActiveWorkbook.Sheets.Add


--
HTH

Bob Phillips

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

"Dan" wrote in message
...
What I have is if a function is called:

If " some function" Then
ActiveWorkbook.Sheets.Add
End If

Where in the above statement do I insert your statements?

With ActiveWorkbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
End With

Dan


ActiveWorkbook.Sheets.Add


"Bob Phillips" wrote:

With ActiveWorkbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
End With


--
HTH

Bob Phillips

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

"Dan" wrote in message
...
I have a function that adds a new work when needed

'Add A New Sheet
ActiveWorkbook.Sheets.Add

The problem is that when the sheet is inserted it is placed at the

beginning
of the workbook. Sheet2 will appear before Sheet1.

I want to automate the process of moving Sheet2 after Sheet1 and all
subsequent Sheets (3, 4, 5 ...)

Sheets("Sheet2").Select
Sheets("Sheet2").Move After:=Sheets(1)

How do I use a counter/variable in place of the "2" so that each time

I
call
the "ActiveWorkbook.Sheets.Add" it will add the new Sheet to the end?

Thanks








  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
dan dan is offline
external usenet poster
 
Posts: 866
Default Moving Sheets within a workbook

Thanks. Works great.

"Bob Phillips" wrote:

Instead of this

ActiveWorkbook.Sheets.Add


--
HTH

Bob Phillips

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

"Dan" wrote in message
...
What I have is if a function is called:

If " some function" Then
ActiveWorkbook.Sheets.Add
End If

Where in the above statement do I insert your statements?

With ActiveWorkbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
End With

Dan


ActiveWorkbook.Sheets.Add


"Bob Phillips" wrote:

With ActiveWorkbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
End With


--
HTH

Bob Phillips

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

"Dan" wrote in message
...
I have a function that adds a new work when needed

'Add A New Sheet
ActiveWorkbook.Sheets.Add

The problem is that when the sheet is inserted it is placed at the
beginning
of the workbook. Sheet2 will appear before Sheet1.

I want to automate the process of moving Sheet2 after Sheet1 and all
subsequent Sheets (3, 4, 5 ...)

Sheets("Sheet2").Select
Sheets("Sheet2").Move After:=Sheets(1)

How do I use a counter/variable in place of the "2" so that each time

I
call
the "ActiveWorkbook.Sheets.Add" it will add the new Sheet to the end?

Thanks







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting a single sheet from a volume of sheets in a workbook No News Excel Worksheet Functions 12 July 1st 06 05:29 AM
Workbook / sheets and Double Monitor ? guzzi Excel Discussion (Misc queries) 7 June 12th 06 01:31 PM
How to calculate percentage acroos sheets in a workbook tosh105 Excel Discussion (Misc queries) 5 April 27th 06 10:39 PM
Finding specific sheets within a workbook Roy Excel Discussion (Misc queries) 2 August 23rd 05 06:40 PM
How to hyperlink from a workbook to sheets in another workbook? MJOHNSON Excel Worksheet Functions 0 February 17th 05 08:31 PM


All times are GMT +1. The time now is 03:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"