What I am after is placing the cursor in the desired cell of the
desired sheet so that when I copy and paste to it, I am certain of the
location of the paste.
What I do is open a three sheet 2k3 format workbook and delete the
first row of all three, then save it in 2k7 format so I can increase the
data set size, then close and re-open that to allow it to actually
function in 2k7 mode, then move the cursor to the end of the first sheet,
then mark and copy the second, and paste it into the first at that end
point, the repeat with the third, then delete the second and third, then
save again
My current code fails because being from a recorded macro, it carries
the direct cell reference instead of my cursor moves to get to the end of
the current data set before I paste, and that does not work when I open a
file that has more records in it than the previous had (or less).
My current code uses the last suggestion I got in this thread before,
and is untried, but here 'tis, see if you can see any easier way. The
database itself is at:
http://www.hometheaterinfo.com/download/dvdlist.zip
It shrinks from 46 MB to 19 MB after I do this conversion. It also
makes it easier to query and use as a flat file database.
The macro is quoted below:
Sub BookMorpher()
'this sub opens the downloaded 2k3 file, saves it as a 2k7 format,
'then concatenates the contents of two segmented sheets of data
'onto the tail of the first sheet, then deletes the two segments
' Open the downloaded 2ks version file
Workbooks.Open Filename:="C:\DVD_Image_Database\temp\dvdlist.xls"
Sheets("a-f").Select
'rename the first sheet
Sheets("a-f").Name = "DVDs"
'shift the ID column to the correct location for all three sheets
Columns("N:N").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Sheets("g-o").Select
Columns("N:N").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Sheets("p-z").Select
Columns("N:N").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
'delete the top row of all three sheets
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Sheets("g-o").Select
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Sheets("DVDs").Select
Rows("1:1").Select
Selection.Delete Shift:=xlUp
'Move to the end of the DVDs sheet
Range("A1").Select
Range("A1").End(xlDown).Offset(1, 0).Select
'Save as then re-open the 2k7 file format workbook
'this is required as the saved-as sheet will not
'accept the pastes until it has been closed and re-opened
ActiveWorkbook.SaveAs Filename:="C:\DVD_Image_Database\dvdlist.xlsx",
_
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Workbooks.Open Filename:="C:\DVD_Image_Database\dvdlist.xlsx"
'Copy the segmented sheets to the end of the first sheet
Sheets("g-o").Select
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DVDs").Select
Range("A1").Select
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste
Range("A1").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Sheets("p-z").Select
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DVDs").Select
ActiveSheet.Paste
'delete the un-needed segmented sheets, leaving only the primary data set
Sheets("p-z").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete
Sheets("g-o").Select
ActiveWindow.SelectedSheets.Delete
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
ActiveWorkbook.Save
ActiveWindow.Close
End Sub