Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Select certain tabs using macro

I am working with a workbook that has over 40 tabs (worksheets). Each
worksheet is a department report and the last report is the one I need to
select for each department and copy it into a new workbook. The name of the
worksheets to be selected copied and pasted is "xxxxx-RSS Upload" where x is
the department number. I was trying to find a property that could only select
the "Upload" part of the worksheet name as a common denominator to select
multiple worksheets that end with that text string. Can somebody provide a
code that will do this??? I started of like this but cannot come up with a
condition:

Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws. 'contains Upload at the end of the text string
ws.Activate
ws.Select
ws.copy After:= workbooks("NewBook").'how do I paste it as the last
worksheet?
End If
Next ws
End Sub
Thanks in advance for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Select certain tabs using macro

Hi,
Try
'''----------------------------------------------------------------------------
Option Compare Text '''<<<< put this row at the top of the module
''' It enables 'A'='a' for text comparison
Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws like "*Upload" then
'''ws.Activate <-- no need
'''ws.Select <-- no need
ws.copy After:= ws.parent.worksheets(ws.parent.worksheets.count)
End If
Next ws
End Sub
''' ------------------------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"FLORERO" wrote:

I am working with a workbook that has over 40 tabs (worksheets). Each
worksheet is a department report and the last report is the one I need to
select for each department and copy it into a new workbook. The name of the
worksheets to be selected copied and pasted is "xxxxx-RSS Upload" where x is
the department number. I was trying to find a property that could only select
the "Upload" part of the worksheet name as a common denominator to select
multiple worksheets that end with that text string. Can somebody provide a
code that will do this??? I started of like this but cannot come up with a
condition:

Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws. 'contains Upload at the end of the text string
ws.Activate
ws.Select
ws.copy After:= workbooks("NewBook").'how do I paste it as the last
worksheet?
End If
Next ws
End Sub
Thanks in advance for your help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Select certain tabs using macro

.... just realized my code copies the sheets at the end of the same book, but
seems like you try to copy to another book. In that case, say the new book is
"NewBook", replace:
ws.copy After:= ws.parent.worksheets(ws.parent.worksheets.count)
by
ws.copy After:= workbooks("newbook"). _
worksheets(workbooks("newbook").worksheets.count)
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"sebastienm" wrote:

Hi,
Try
'''----------------------------------------------------------------------------
Option Compare Text '''<<<< put this row at the top of the module
''' It enables 'A'='a' for text comparison
Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws like "*Upload" then
'''ws.Activate <-- no need
'''ws.Select <-- no need
ws.copy After:= ws.parent.worksheets(ws.parent.worksheets.count)
End If
Next ws
End Sub
''' ------------------------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"FLORERO" wrote:

I am working with a workbook that has over 40 tabs (worksheets). Each
worksheet is a department report and the last report is the one I need to
select for each department and copy it into a new workbook. The name of the
worksheets to be selected copied and pasted is "xxxxx-RSS Upload" where x is
the department number. I was trying to find a property that could only select
the "Upload" part of the worksheet name as a common denominator to select
multiple worksheets that end with that text string. Can somebody provide a
code that will do this??? I started of like this but cannot come up with a
condition:

Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws. 'contains Upload at the end of the text string
ws.Activate
ws.Select
ws.copy After:= workbooks("NewBook").'how do I paste it as the last
worksheet?
End If
Next ws
End Sub
Thanks in advance for your help

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Select certain tabs using macro

I tried running the code but I get Run Time error 438 'Object does not
support this property or method' for the following line:

If ws like "*Upload" then

I am using Excel 2003, is that the reason??
"sebastienm" wrote:

... just realized my code copies the sheets at the end of the same book, but
seems like you try to copy to another book. In that case, say the new book is
"NewBook", replace:
ws.copy After:= ws.parent.worksheets(ws.parent.worksheets.count)
by
ws.copy After:= workbooks("newbook"). _
worksheets(workbooks("newbook").worksheets.count)
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"sebastienm" wrote:

Hi,
Try
'''----------------------------------------------------------------------------
Option Compare Text '''<<<< put this row at the top of the module
''' It enables 'A'='a' for text comparison
Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws like "*Upload" then
'''ws.Activate <-- no need
'''ws.Select <-- no need
ws.copy After:= ws.parent.worksheets(ws.parent.worksheets.count)
End If
Next ws
End Sub
''' ------------------------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"FLORERO" wrote:

I am working with a workbook that has over 40 tabs (worksheets). Each
worksheet is a department report and the last report is the one I need to
select for each department and copy it into a new workbook. The name of the
worksheets to be selected copied and pasted is "xxxxx-RSS Upload" where x is
the department number. I was trying to find a property that could only select
the "Upload" part of the worksheet name as a common denominator to select
multiple worksheets that end with that text string. Can somebody provide a
code that will do this??? I started of like this but cannot come up with a
condition:

Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws. 'contains Upload at the end of the text string
ws.Activate
ws.Select
ws.copy After:= workbooks("NewBook").'how do I paste it as the last
worksheet?
End If
Next ws
End Sub
Thanks in advance for your help

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Select certain tabs using macro

For i = 1 To Sheets.Count
If UCase(Right(Trim(Sheets(i).Name), 6)) = "UPLOAD" Then
Sheets(i).Select
End If
Next

try adapting this
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"FLORERO" wrote:

I am working with a workbook that has over 40 tabs (worksheets). Each
worksheet is a department report and the last report is the one I need to
select for each department and copy it into a new workbook. The name of the
worksheets to be selected copied and pasted is "xxxxx-RSS Upload" where x is
the department number. I was trying to find a property that could only select
the "Upload" part of the worksheet name as a common denominator to select
multiple worksheets that end with that text string. Can somebody provide a
code that will do this??? I started of like this but cannot come up with a
condition:

Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws. 'contains Upload at the end of the text string
ws.Activate
ws.Select
ws.copy After:= workbooks("NewBook").'how do I paste it as the last
worksheet?
End If
Next ws
End Sub
Thanks in advance for your help



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Select certain tabs using macro

Your code only goes through all the worksheets but does not copy into new
workbook. Can you provide details?? Thanks

"John Bundy" wrote:

For i = 1 To Sheets.Count
If UCase(Right(Trim(Sheets(i).Name), 6)) = "UPLOAD" Then
Sheets(i).Select
End If
Next

try adapting this
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"FLORERO" wrote:

I am working with a workbook that has over 40 tabs (worksheets). Each
worksheet is a department report and the last report is the one I need to
select for each department and copy it into a new workbook. The name of the
worksheets to be selected copied and pasted is "xxxxx-RSS Upload" where x is
the department number. I was trying to find a property that could only select
the "Upload" part of the worksheet name as a common denominator to select
multiple worksheets that end with that text string. Can somebody provide a
code that will do this??? I started of like this but cannot come up with a
condition:

Sub macro1_()
Dim ws As Worksheet
For Each ws In Worksheets
If ws. 'contains Upload at the end of the text string
ws.Activate
ws.Select
ws.copy After:= workbooks("NewBook").'how do I paste it as the last
worksheet?
End If
Next ws
End Sub
Thanks in advance for your help

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
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Select Various tabs using VBA Don Wiss Excel Programming 0 October 1st 06 08:13 PM
Select Various tabs using VBA Chris Excel Programming 1 October 1st 06 06:39 PM
Excel - option to select the same header for mutliple tabs Sarah Beattie Setting up and Configuration of Excel 3 August 31st 06 04:20 PM
Need help with using VBA to select tabs in Excel MFINE Excel Programming 1 July 20th 06 01:56 AM


All times are GMT +1. The time now is 09:45 PM.

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"