Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 158
Default Macro to combine worksheets data - overwrites existing

Hello:

I've written this macro (with a reasonable amount of support from this
group already) to copy data from several worksheets and paste it into
a "Master" worksheet. However, I've made a few changes to the
spreadsheet (rows for the header and a few additional columns) and
instead of appending data, it overwrites everything. How do I tell it
to go to the last row containing data?

Sub UpdateMaster()
'This macro updates the Master Spreadsheet, it is linked to a button
on the Reports tab

' Clears existing data on Master spreadsheet, except for header
row
Sheets("Master").Select
Application.Calculation = xlCalculationManual
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.ClearContents

' Copies data from each spreadsheet in the workbook, excluding
sheets named in Case, and pastes data in Master
For Each thing In Sheets
Select Case thing.Name
Case "Master", "Reports", "Test Filter", "ReportOutput",
"Diagram", "Master2"
'do nothing
Case Else
Sheets(thing.Name).Range("3:1000").Copy

Sheets("Master").Range("A65536").End(xlUp).Offset( 1).PasteSpecial
End Select
Next
Sheets("Master").Activate
Range("A3").Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Macro to combine worksheets data - overwrites existing

Hi

See this page for example code
http://www.rondebruin.nl/copy2.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
Hello:

I've written this macro (with a reasonable amount of support from this
group already) to copy data from several worksheets and paste it into
a "Master" worksheet. However, I've made a few changes to the
spreadsheet (rows for the header and a few additional columns) and
instead of appending data, it overwrites everything. How do I tell it
to go to the last row containing data?

Sub UpdateMaster()
'This macro updates the Master Spreadsheet, it is linked to a button
on the Reports tab

' Clears existing data on Master spreadsheet, except for header
row
Sheets("Master").Select
Application.Calculation = xlCalculationManual
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.ClearContents

' Copies data from each spreadsheet in the workbook, excluding
sheets named in Case, and pastes data in Master
For Each thing In Sheets
Select Case thing.Name
Case "Master", "Reports", "Test Filter", "ReportOutput",
"Diagram", "Master2"
'do nothing
Case Else
Sheets(thing.Name).Range("3:1000").Copy

Sheets("Master").Range("A65536").End(xlUp).Offset( 1).PasteSpecial
End Select
Next
Sheets("Master").Activate
Range("A3").Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 158
Default Macro to combine worksheets data - overwrites existing

Hi,

Thanks for this Ron, but I am having trouble with your "LastRow"
command. I get a "Sub or Function not defined" error.

I simply copied your code directly.


Using Excel 2002, SP3


S

On May 1, 3:03*pm, "Ron de Bruin" wrote:
Hi

See this page for example codehttp://www.rondebruin.nl/copy2.htm

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



wrote in ...
Hello:


I've written this macro (with a reasonable amount of support from this
group already) to copy data from several worksheets and paste it into
a "Master" worksheet. However, I've made a few changes to the
spreadsheet (rows for the header and a few additional columns) and
instead of appending data, it overwrites everything. How do I tell it
to go to the last row containing data?


Sub UpdateMaster()
'This macro updates the Master Spreadsheet, it is linked to a button
on the Reports tab


* *' Clears existing data on Master spreadsheet, except for header
row
Sheets("Master").Select
Application.Calculation = xlCalculationManual
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.ClearContents


* *' Copies data from each spreadsheet in the workbook, excluding
sheets named in Case, and pastes data in Master
For Each thing In Sheets
* *Select Case thing.Name
* * *Case "Master", "Reports", "Test Filter", "ReportOutput",
"Diagram", "Master2"
* * * * * 'do nothing
* * *Case Else
* * * Sheets(thing.Name).Range("3:1000").Copy


Sheets("Master").Range("A65536").End(xlUp).Offset( 1).PasteSpecial
* * End Select
Next
Sheets("Master").Activate
Range("A3").Select
End Sub- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Macro to combine worksheets data - overwrites existing

It is simple Copy the LastRow function also in the module



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
Hi,

Thanks for this Ron, but I am having trouble with your "LastRow"
command. I get a "Sub or Function not defined" error.

I simply copied your code directly.


Using Excel 2002, SP3


S

On May 1, 3:03 pm, "Ron de Bruin" wrote:
Hi

See this page for example codehttp://www.rondebruin.nl/copy2.htm

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



wrote in ...
Hello:


I've written this macro (with a reasonable amount of support from this
group already) to copy data from several worksheets and paste it into
a "Master" worksheet. However, I've made a few changes to the
spreadsheet (rows for the header and a few additional columns) and
instead of appending data, it overwrites everything. How do I tell it
to go to the last row containing data?


Sub UpdateMaster()
'This macro updates the Master Spreadsheet, it is linked to a button
on the Reports tab


' Clears existing data on Master spreadsheet, except for header
row
Sheets("Master").Select
Application.Calculation = xlCalculationManual
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.ClearContents


' Copies data from each spreadsheet in the workbook, excluding
sheets named in Case, and pastes data in Master
For Each thing In Sheets
Select Case thing.Name
Case "Master", "Reports", "Test Filter", "ReportOutput",
"Diagram", "Master2"
'do nothing
Case Else
Sheets(thing.Name).Range("3:1000").Copy


Sheets("Master").Range("A65536").End(xlUp).Offset( 1).PasteSpecial
End Select
Next
Sheets("Master").Activate
Range("A3").Select
End Sub- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 158
Default Macro to combine worksheets data - overwrites existing

Thank you Ron! I just need to read all the text before I try and
decipher the code. I will try to be more vigilant in the future.

This looks great.


S

On May 1, 3:39*pm, "Ron de Bruin" wrote:
It is simple Copy the LastRow function also in the module

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

wrote in ...

Hi,

Thanks for this Ron, but I am having trouble with your "LastRow"
command. I get a "Sub or Function not defined" error.

I simply copied your code directly.

Using Excel 2002, SP3

S

On May 1, 3:03 pm, "Ron de Bruin" wrote:



Hi


See this page for example codehttp://www.rondebruin.nl/copy2.htm


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


wrote in ...
Hello:


I've written this macro (with a reasonable amount of support from this
group already) to copy data from several worksheets and paste it into
a "Master" worksheet. However, I've made a few changes to the
spreadsheet (rows for the header and a few additional columns) and
instead of appending data, it overwrites everything. How do I tell it
to go to the last row containing data?


Sub UpdateMaster()
'This macro updates the Master Spreadsheet, it is linked to a button
on the Reports tab


' Clears existing data on Master spreadsheet, except for header
row
Sheets("Master").Select
Application.Calculation = xlCalculationManual
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.ClearContents


' Copies data from each spreadsheet in the workbook, excluding
sheets named in Case, and pastes data in Master
For Each thing In Sheets
Select Case thing.Name
Case "Master", "Reports", "Test Filter", "ReportOutput",
"Diagram", "Master2"
'do nothing
Case Else
Sheets(thing.Name).Range("3:1000").Copy


Sheets("Master").Range("A65536").End(xlUp).Offset( 1).PasteSpecial
End Select
Next
Sheets("Master").Activate
Range("A3").Select
End Sub- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Macro to combine worksheets data - overwrites existing

You are not the only one that not read the info on my pages <g

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
Thank you Ron! I just need to read all the text before I try and
decipher the code. I will try to be more vigilant in the future.

This looks great.


S

On May 1, 3:39 pm, "Ron de Bruin" wrote:
It is simple Copy the LastRow function also in the module

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

wrote in ...

Hi,

Thanks for this Ron, but I am having trouble with your "LastRow"
command. I get a "Sub or Function not defined" error.

I simply copied your code directly.

Using Excel 2002, SP3

S

On May 1, 3:03 pm, "Ron de Bruin" wrote:



Hi


See this page for example codehttp://www.rondebruin.nl/copy2.htm


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


wrote in ...
Hello:


I've written this macro (with a reasonable amount of support from this
group already) to copy data from several worksheets and paste it into
a "Master" worksheet. However, I've made a few changes to the
spreadsheet (rows for the header and a few additional columns) and
instead of appending data, it overwrites everything. How do I tell it
to go to the last row containing data?


Sub UpdateMaster()
'This macro updates the Master Spreadsheet, it is linked to a button
on the Reports tab


' Clears existing data on Master spreadsheet, except for header
row
Sheets("Master").Select
Application.Calculation = xlCalculationManual
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.ClearContents


' Copies data from each spreadsheet in the workbook, excluding
sheets named in Case, and pastes data in Master
For Each thing In Sheets
Select Case thing.Name
Case "Master", "Reports", "Test Filter", "ReportOutput",
"Diagram", "Master2"
'do nothing
Case Else
Sheets(thing.Name).Range("3:1000").Copy


Sheets("Master").Range("A65536").End(xlUp).Offset( 1).PasteSpecial
End Select
Next
Sheets("Master").Activate
Range("A3").Select
End Sub- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


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
Bloomberg overwrites data-need to save stream of data in a new she Melanie Excel Worksheet Functions 2 December 27th 07 05:42 PM
How to merge / combine several worksheets into one new worksheet without VBA / Macro? FOR EXPERTS [email protected] Excel Worksheet Functions 9 August 13th 07 04:19 AM
Worksheets.add in VBScript overwrites existing worksheet donparkerjr Excel Worksheet Functions 3 November 9th 06 07:09 PM
How do I combine data from 4 worksheets? grndmntjd Excel Worksheet Functions 1 September 6th 06 10:03 PM
Combine Data from 2 worksheets Krefty Excel Discussion (Misc queries) 3 January 14th 05 11:40 PM


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

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

About Us

"It's about Microsoft Excel"