ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Move of Sheet screws up Stored Sheets (https://www.excelbanter.com/excel-programming/365214-move-sheet-screws-up-stored-sheets.html)

Grasshopper

Move of Sheet screws up Stored Sheets
 
When I add a workbook I get only 1 sheet, not sure why it's not 3, but
nonetheless there's the 1. I use the Item( 1 ) method to get the pointer of
the worksheet. I store it for future use. If I add a worksheet, I store the
pointer as well. All is fine. Item, Index, Name both work fine and I can
select between the two without problems. If I do a Move of a sheet then a
call to get the Name, Item, Index properties fails. Any ideas? Thanks.
-G-

Jim Cone

Move of Sheet screws up Stored Sheets
 
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub MakeAnotherAndMoveIt()
Dim objFirst As Excel.Worksheet
Dim objSecond As Excel.Worksheet
Dim objWB As Excel.Workbook

'Create new workbook
Set objWB = Workbooks.Add

'Get reference to the first sheet.
Set objFirst = objWB.Worksheets(1)

'Add new sheet after the first sheet and secure a reference to it..
Set objSecond = objWB.Worksheets.Add(after:=objFirst, Count:=1)

'Move the new sheet to the first position again.
objSecond.Move befo=objFirst
End Sub
'-------------------


"Grasshopper"

wrote in message
When I add a workbook I get only 1 sheet, not sure why it's not 3, but
nonetheless there's the 1. I use the Item( 1 ) method to get the pointer of
the worksheet. I store it for future use. If I add a worksheet, I store the
pointer as well. All is fine. Item, Index, Name both work fine and I can
select between the two without problems. If I do a Move of a sheet then a
call to get the Name, Item, Index properties fails. Any ideas? Thanks.
-G-


All times are GMT +1. The time now is 04:46 PM.

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