Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Grouping and moving worksheets by name using VBA?


Hi all,
Is it possible to group sheets ending with a certain name and move them
to a new workbook in my documents named by the name i am grouping by?
Lets say i have 20 sheets each named "**** Today" where **** is a
variable, is it possible in VBA to group all the sheets with name
ending in Today and move them to a new workbook in my documents and
name the workbook "Today"?

Hope you can help!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=546346

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Grouping and moving worksheets by name using VBA?

Dim bReplace As Boolean, sh As Worksheet
Dim bk As Workbook
bReplace = True
For Each sh In Worksheets
If sh.Name Like "*Today" Then
sh.Select Replace:=bDontReplace
bReplace = False
End If
Next
ActiveWindow.SelectedSheets.Move
ActiveWorkbook.SaveAs Filename:=bk.Path & "\" & "Today.xls"

--
Regards,
Tom Ogilvy

"Simon Lloyd"
wrote in message
...

Hi all,
Is it possible to group sheets ending with a certain name and move them
to a new workbook in my documents named by the name i am grouping by?
Lets say i have 20 sheets each named "**** Today" where **** is a
variable, is it possible in VBA to group all the sheets with name
ending in Today and move them to a new workbook in my documents and
name the workbook "Today"?

Hope you can help!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile:

http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=546346



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Grouping and moving worksheets by name using VBA?


Hi Tom thanks for the reply,

i tried the code below using an input box to select the sheet name, i
have tried variations but it moved the sheets that were not named in
the input box. If a sheet is called " here Today" and another "there
Today" and another "blog Today" i want to select all sheets ending in
the word today and move them to a new workbook call it Today and save
in my documents. here's the code ive been bumbling with! of course as
usual it doesnt quite work.
Hope you can help....again!
Regards,
Simon

Sub shtmove()
Dim bReplace As Boolean, sh As Worksheet
Dim bk As Workbook
Dim I2 As Integer
For I2 = 1 To 1
t1 = InputBox("Enter Last Name Of Sheets To Be Stored", "Which
Sheets To Store?", "")
bReplace = True
For Each sh In Worksheets
If sh.Name Like t1.Value Then
sh.Select Replace:=bDontReplace
bReplace = False
End If
Next
ActiveWindow.SelectedSheets.Move
ActiveWorkbook.SaveAs Filename:=bk.Path & "\" & t1.Value & ".xls"
Next
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=546346

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Grouping and moving worksheets by name using VBA?


Sorry just forgot to mention the code you supplied Tom halts a
ActiveWindow.SelectedSheets.Move
I think this is because it selected all visible sheets so would leav
the active workbook without a visible sheet.

Regards,
simo

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=54634

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Grouping and moving worksheets by name using VBA?


Hi Tom, I have tried working with this code but just can't get it to
work correctly, if its any help the Tabs are automatically coloured
Tab.ColorIndex = 40 this is done as the newly created sheet is named
during the course of creating these sheets over a 100 may have been
created which is why i wanted them to get moved by their last name to
another workbook called the same name!

Is there any further help you could supply with this?

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=546346



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
Grouping on protected worksheets wnwilkerson Excel Worksheet Functions 4 April 22nd 10 09:15 PM
Moving between worksheets Damon Excel Discussion (Misc queries) 3 July 7th 06 05:31 PM
separate worksheet into multiple worksheets by grouping BPM001 Excel Worksheet Functions 1 November 5th 05 02:48 AM
grouping hidden worksheets bennyob Excel Discussion (Misc queries) 5 November 5th 05 12:39 AM
Data Grouping when Worksheets Protected Allison[_2_] Excel Programming 1 March 6th 04 03:46 PM


All times are GMT +1. The time now is 08:46 AM.

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

About Us

"It's about Microsoft Excel"