Error 1004, pasting merged cells

S

Simon

‘Alpha is a tab in another workbook (WBSEL) which is copied and
pasted
in to a newly added workbook (via VBA). However this is an 1004
error
relating to a merged cell (A1:J1).

For some reason it won’t copy due to the merged cell? Why is this,
the whole sheet is copied, why is it dependent on a cell?


With WBAlpha
.SaveAs Filename:="N:\mis\" & MyRange.Value & MyRange2.Value
&
"\" & "Alpha Figures" & " " & MyRange.Value & MyRange2.Value & ".xls"
End With


WBSEL.Activate
Sheets("Alpha").Select
Sheets("Alpha").Copy Before:=WBAlpha.Sheets(1)
WBAlpha.Activate
Sheets("Alpha").Paste
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete


With WBAlpha
.SendMail Recipients:=Array(RngEmailTest2.Value, RngEmailTest.Value)
.Close SaveChanges:=True


Thanks, Simon (the MyRange.Value occurances are merely a date
stamping for the previous month.
 
J

Jim Rech

This line of your code copies the sheet and everything on it:

Sheets("Alpha").Copy Before:=WBAlpha.Sheets(1)

I don't see what the Paste is trying to do.

--
Jim
‘Alpha is a tab in another workbook (WBSEL) which is copied and
pasted
in to a newly added workbook (via VBA). However this is an 1004
error
relating to a merged cell (A1:J1).

For some reason it won’t copy due to the merged cell? Why is this,
the whole sheet is copied, why is it dependent on a cell?


With WBAlpha
.SaveAs Filename:="N:\mis\" & MyRange.Value & MyRange2.Value
&
"\" & "Alpha Figures" & " " & MyRange.Value & MyRange2.Value & ".xls"
End With


WBSEL.Activate
Sheets("Alpha").Select
Sheets("Alpha").Copy Before:=WBAlpha.Sheets(1)
WBAlpha.Activate
Sheets("Alpha").Paste
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete


With WBAlpha
..SendMail Recipients:=Array(RngEmailTest2.Value, RngEmailTest.Value)
..Close SaveChanges:=True


Thanks, Simon (the MyRange.Value occurances are merely a date
stamping for the previous month.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top