Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to copy a target sheet from slaves from and paste/overwrite into master

Hi guys,

I'm looking for help with a sub* which can automate this process:

I've opened 3 books:
Summary_May2005.xls
11002404_abcdef.xls
11003702_abcdef.xls

In Summary.xls
there will be sheets named as: 11002404, 11003702, etc

These sheets are named with the project nos,
i.e. the first 8 digits of the books' filenames :
11002404_abcdef.xls
11003702_abcdef.xls

In each:
11002404_abcdef.xls
11003702_abcdef.xls

there will be a sheet named: Monthly Status Report

This sheet is the one which needs to be copied and pasted over as values
into
Summary_May2005.xls (into the corresponding sheets over there, overwriting
previous data.)

And if the sheet(s) to be copied/pasted over doesn't exist as yet in
Summary_May2005.xls (e.g.: new cases), the copy/paste will then be done in a
new sheet(s) created which will then be named after the first 8 digits of
the file(s).

*sub to run from Summary_May2005.xls

Grateful for any insights. Thanks.
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


  #2   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to copy a target sheet from slaves from and paste/overwrite into master

Hi guys,

Am willing to pare down the specs substantially <g. I'm really not sure
which part of the post / process proved insurmountable. Hopeful for some
comments / experience to be thrown this way. Thanks.
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Sub to copy a target sheet from slaves from and paste/overwrite into master

Lightly tested but no error-checking provided!

Sub PasteNewInfo()
Dim wb As Workbook, wbSummary As Workbook
Set wbSummary = Workbooks("Summary_May2005.xls")
For Each wb In Workbooks
If wb.Name < wbSummary.Name Then
If Not WorksheetExists(Left(wb.Name, 8), wbSummary.Name) Then
wbSummary.Worksheets.Add.Name = Left(wb.Name, 8)
End If
wb.Worksheets("Monthly Status Report").Cells.Copy _
wbSummary.Worksheets(Left(wb.Name, 8)).Range("A1")
End If
Next
Application.CutCopyMode = False
End Sub

Function WorksheetExists(wsName As String, _
Optional wbName As String) As Boolean
If wbName = "" Then wbName = _
ActiveWorkbook.Name
On Error Resume Next
WorksheetExists = CBool(Len(Workbooks(wbName) _
.Worksheets(wsName).Name))
End Function

---

Vasant




"Max" wrote in message
...
Hi guys,

I'm looking for help with a sub* which can automate this process:

I've opened 3 books:
Summary_May2005.xls
11002404_abcdef.xls
11003702_abcdef.xls

In Summary.xls
there will be sheets named as: 11002404, 11003702, etc

These sheets are named with the project nos,
i.e. the first 8 digits of the books' filenames :
11002404_abcdef.xls
11003702_abcdef.xls

In each:
11002404_abcdef.xls
11003702_abcdef.xls

there will be a sheet named: Monthly Status Report

This sheet is the one which needs to be copied and pasted over as values
into
Summary_May2005.xls (into the corresponding sheets over there, overwriting
previous data.)

And if the sheet(s) to be copied/pasted over doesn't exist as yet in
Summary_May2005.xls (e.g.: new cases), the copy/paste will then be done in

a
new sheet(s) created which will then be named after the first 8 digits of
the file(s).

*sub to run from Summary_May2005.xls

Grateful for any insights. Thanks.
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




  #4   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to copy a target sheet from slaves from and paste/overwrite into master

A quick acknowledgement and BIG thanks, Vasant!
I'll certainly try your offering and post back further here. Cheers.
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


  #5   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to copy a target sheet from slaves from and paste/overwrite into master

Sorry ... despite several tries running the sub, I kept hitting this error:

Run time error '9': Subscript out of range

Debug pointed at this line:

wb.Worksheets("Monthly Status Report").Cells.Copy _
wbSummary.Worksheets(Left(wb.Name, 8)).Range("A1")

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Sub to copy a target sheet from slaves from and paste/overwrite into master

In that case, most likely all the open workbooks (with the exception of the
destination workbook) do not contain a worksheet named "Monthly Status
Report". Or perhaps a hidden workbook such as Personal.xls is open (which of
course would not have a worksheet with this name).

--

Vasant




"Max" wrote in message
...
Sorry ... despite several tries running the sub, I kept hitting this

error:

Run time error '9': Subscript out of range

Debug pointed at this line:

wb.Worksheets("Monthly Status Report").Cells.Copy _
wbSummary.Worksheets(Left(wb.Name, 8)).Range("A1")

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




  #7   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to copy a target sheet from slaves from and paste/overwrite into master

... Or perhaps a hidden workbook such as Personal.xls is open
(which of course would not have a worksheet with this name).


Yes, think this is the culprit. What can I do to proceed ?

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


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
Paste all sheets into one master sheet Its me[_3_] Excel Worksheet Functions 5 August 3rd 09 03:30 AM
Combining all tabs into 1 master w/o copy&paste Webs Excel Worksheet Functions 1 March 6th 09 12:29 AM
Overwrite Master sheet when using merge macro Mark Jackson Excel Programming 3 June 8th 05 09:33 AM
copy to another wb and name the target sheet (XL2000) robert burger Excel Programming 4 September 25th 04 03:17 AM
copy to another wb and name the target sheet (XL2000) robert burger Excel Programming 1 September 24th 04 04:40 PM


All times are GMT +1. The time now is 06:54 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"