Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
inserting sheets in excel
I am building an automated macro where depending on a certain conditions a
formatted sheet is inserted and key fields from the master spreadsheet, this may happen more than once in the spreadsheet. I can do it once, but cannot find out how to select the last created sheet where I create more than one sheet so I can insert the default data. Any help would be appreciated. thanks -- neil |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
inserting sheets in excel
When you create it, it will be the activesheet. It might be useful to
assign it a sequential style unique name at that time. -- Regards, Tom Ogilvy "neil" wrote in message ... I am building an automated macro where depending on a certain conditions a formatted sheet is inserted and key fields from the master spreadsheet, this may happen more than once in the spreadsheet. I can do it once, but cannot find out how to select the last created sheet where I create more than one sheet so I can insert the default data. Any help would be appreciated. thanks -- neil |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
inserting sheets in excel
Makes sense, but how do I do it?
thanks Neil "Tom Ogilvy" wrote: When you create it, it will be the activesheet. It might be useful to assign it a sequential style unique name at that time. -- Regards, Tom Ogilvy "neil" wrote in message ... I am building an automated macro where depending on a certain conditions a formatted sheet is inserted and key fields from the master spreadsheet, this may happen more than once in the spreadsheet. I can do it once, but cannot find out how to select the last created sheet where I create more than one sheet so I can insert the default data. Any help would be appreciated. thanks -- neil |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
inserting sheets in excel
Dim i as Long
Dim sh as Worksheet i = 0 for each sh in Worksheets if lcase(Left(sh.name,12)) = "myaddedsheet" then i = i + 1 Next End Sub worksheets.add After:=worksheets(worksheets.count) Activesheet.Name = "MyAddedSheet" & i + 1 -- Regards, Tom Ogilvy "neil" wrote in message ... Makes sense, but how do I do it? thanks Neil "Tom Ogilvy" wrote: When you create it, it will be the activesheet. It might be useful to assign it a sequential style unique name at that time. -- Regards, Tom Ogilvy "neil" wrote in message ... I am building an automated macro where depending on a certain conditions a formatted sheet is inserted and key fields from the master spreadsheet, this may happen more than once in the spreadsheet. I can do it once, but cannot find out how to select the last created sheet where I create more than one sheet so I can insert the default data. Any help would be appreciated. thanks -- neil |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
inserting sheets in excel
I had to change lines:
Next End Sub to End If Next Right? "Tom Ogilvy" wrote in message ... Dim i as Long Dim sh as Worksheet i = 0 for each sh in Worksheets if lcase(Left(sh.name,12)) = "myaddedsheet" then i = i + 1 Next End Sub worksheets.add After:=worksheets(worksheets.count) Activesheet.Name = "MyAddedSheet" & i + 1 -- Regards, Tom Ogilvy "neil" wrote in message ... Makes sense, but how do I do it? thanks Neil "Tom Ogilvy" wrote: When you create it, it will be the activesheet. It might be useful to assign it a sequential style unique name at that time. -- Regards, Tom Ogilvy "neil" wrote in message ... I am building an automated macro where depending on a certain conditions a formatted sheet is inserted and key fields from the master spreadsheet, this may happen more than once in the spreadsheet. I can do it once, but cannot find out how to select the last created sheet where I create more than one sheet so I can insert the default data. Any help would be appreciated. thanks -- neil |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
inserting sheets in excel
As Jim said (thanks)
Dim i as Long Dim sh as Worksheet i = 0 for each sh in Worksheets if lcase(Left(sh.name,12)) = "myaddedsheet" then i = i + 1 end if Next worksheets.add After:=worksheets(worksheets.count) Activesheet.Name = "MyAddedSheet" & i + 1 -- Regards, "Jim May" wrote in message news:vWXYd.75670$%U2.8675@lakeread01... I had to change lines: Next End Sub to End If Next Right? "Tom Ogilvy" wrote in message ... Dim i as Long Dim sh as Worksheet i = 0 for each sh in Worksheets if lcase(Left(sh.name,12)) = "myaddedsheet" then i = i + 1 Next End Sub worksheets.add After:=worksheets(worksheets.count) Activesheet.Name = "MyAddedSheet" & i + 1 -- Regards, Tom Ogilvy "neil" wrote in message ... Makes sense, but how do I do it? thanks Neil "Tom Ogilvy" wrote: When you create it, it will be the activesheet. It might be useful to assign it a sequential style unique name at that time. -- Regards, Tom Ogilvy "neil" wrote in message ... I am building an automated macro where depending on a certain conditions a formatted sheet is inserted and key fields from the master spreadsheet, this may happen more than once in the spreadsheet. I can do it once, but cannot find out how to select the last created sheet where I create more than one sheet so I can insert the default data. Any help would be appreciated. thanks -- neil |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
inserting sheets in excel
dim mstrWks as worksheet
dim newWks as worksheet set mstrwks = activesheet 'worksheets("sheet99") set newwks = worksheets.add Then you can use that newwks variable to do things. newwks.range("a1").value = "Hey, I just added this sheet" newwks.name = format(now,"yyyymmdd_hhmmss") 'a nice unique name??? neil wrote: I am building an automated macro where depending on a certain conditions a formatted sheet is inserted and key fields from the master spreadsheet, this may happen more than once in the spreadsheet. I can do it once, but cannot find out how to select the last created sheet where I create more than one sheet so I can insert the default data. Any help would be appreciated. thanks -- neil -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting sheets into Excel workbook | Excel Discussion (Misc queries) | |||
Inserting Sheets from multiple files | Excel Discussion (Misc queries) | |||
Updating, Deleting and inserting rows over two Excel Sheets | Excel Worksheet Functions | |||
Inserting Sheets and Naming | Excel Programming | |||
Inserting and arranging sheets | Excel Programming |