LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Junior Member
 
Posts: 23
Default How can i not copy the headers?

Hello and thank you in advance.
I have this bit of code that works almost perfectly. It copies all data below the headers on row 3, into a new workbook. If there is data in the sheet then it works fine, however if there is no data then it copies the headers.
how can i make it so it knows theres no data below row 3 and so gives a msgbox to say "nothing to copy"?
here is my code so far:

'*** COPY DATA TO MASTER ARCHIVE ***
' Gather data
Worksheets("Sheet1").Activate
Range("A65536").Select
ActiveCell.End(xlUp).Select
LastRow = ActiveCell.Row

' copy the data
Range("A4:F" & LastRow).Copy

' add the data
MasterFile = "\\my path\Complete archive.xls"
Workbooks.Open (MasterFile)
Worksheets("Sheet1").Activate
Range("A65536").Select
ActiveCell.End(xlUp).Offset(1, 0).Select
NextRow = ActiveCell.Row

' paste the data
Worksheets("Cardiff").Range("A" & NextRow).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A3").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
 
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
Copy spreadsheet with headers - how? Martin ©¿©¬ @nohere.net Excel Discussion (Misc queries) 2 August 13th 09 07:45 PM
Headers and Footers - How to copy? The Hun New Users to Excel 1 March 13th 08 11:00 PM
copy over just columns and headers lbierer Setting up and Configuration of Excel 1 July 14th 06 08:52 PM
Copy Headers and Footers between wookbooks Dave Excel Discussion (Misc queries) 1 May 6th 06 03:47 PM
How can I get headers to copy in charts? KC Charts and Charting in Excel 1 March 17th 06 07:33 PM


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