Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Why does this Macro not work - cut, copy and paste

Morning from a overcast South Africa,

I have this macro that is supposed to copy a worksheet, paste the values and
formats onto a new worksheet and then send the new worksheet via e-mail.

Can you please identify why when copy and pasted onto the new worksheet ,the
calculated cells all have #REF!.

Here is the macro that is causing the problem.

Sub EMail()
'Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Unprotect Password:="Drivers"
Next n
Application.ScreenUpdating = True
'End Sub

Dim wb As Workbook
Application.ScreenUpdating = False
ActiveSheet.Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set wb = ActiveWorkbook
With wb
..SendMail "", _
ThisWorkbook.Names("Spreadsheet_Name").RefersToRan ge.Value
'Range ("E2") & " Payroll MonthEnd figures"
'"This is the Subject line"
..Close False
End With
Application.ScreenUpdating = True
'End Sub

'Sub ProtectAllSheets()
Application.ScreenUpdating = False
'Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="Drivers"
Next n
Application.ScreenUpdating = True
End Sub

Waiting in anticipation.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default Why does this Macro not work - cut, copy and paste

After your paste special | values line, I think you will need this:

Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
SkipBlanks:= False, Transpose:=False
Application.CutCopyMode = False

Hope this helps.

Pete

On Oct 11, 9:54 am, Sunnyskies
wrote:
Morning from a overcast South Africa,

I have this macro that is supposed to copy a worksheet, paste the values and
formats onto a new worksheet and then send the new worksheet via e-mail.

Can you please identify why when copy and pasted onto the new worksheet ,the
calculated cells all have #REF!.

Here is the macro that is causing the problem.

Sub EMail()
'Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Unprotect Password:="Drivers"
Next n
Application.ScreenUpdating = True
'End Sub

Dim wb As Workbook
Application.ScreenUpdating = False
ActiveSheet.Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set wb = ActiveWorkbook
With wb
.SendMail "", _
ThisWorkbook.Names("Spreadsheet_Name").RefersToRan ge.Value
'Range ("E2") & " Payroll MonthEnd figures"
'"This is the Subject line"
.Close False
End With
Application.ScreenUpdating = True
'End Sub

'Sub ProtectAllSheets()
Application.ScreenUpdating = False
'Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="Drivers"
Next n
Application.ScreenUpdating = True
End Sub

Waiting in anticipation.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Why does this Macro not work - cut, copy and paste

Afternoon Pete,

I inserted the script you provided between the lines:
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
and

Set wb = ActiveWorkbook

And unfortunately still get the #REF! on the new worksheet once I had opened
it up.

Any other possible solution?

"Pete_UK" wrote:

After your paste special | values line, I think you will need this:

Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
SkipBlanks:= False, Transpose:=False
Application.CutCopyMode = False

Hope this helps.

Pete

On Oct 11, 9:54 am, Sunnyskies
wrote:
Morning from a overcast South Africa,

I have this macro that is supposed to copy a worksheet, paste the values and
formats onto a new worksheet and then send the new worksheet via e-mail.

Can you please identify why when copy and pasted onto the new worksheet ,the
calculated cells all have #REF!.

Here is the macro that is causing the problem.

Sub EMail()
'Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Unprotect Password:="Drivers"
Next n
Application.ScreenUpdating = True
'End Sub

Dim wb As Workbook
Application.ScreenUpdating = False
ActiveSheet.Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set wb = ActiveWorkbook
With wb
.SendMail "", _
ThisWorkbook.Names("Spreadsheet_Name").RefersToRan ge.Value
'Range ("E2") & " Payroll MonthEnd figures"
'"This is the Subject line"
.Close False
End With
Application.ScreenUpdating = True
'End Sub

'Sub ProtectAllSheets()
Application.ScreenUpdating = False
'Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="Drivers"
Next n
Application.ScreenUpdating = True
End Sub

Waiting in anticipation.




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default Why does this Macro not work - cut, copy and paste

I suggest you step through the macro using F8 to check what is
happening at each point - it looks as if you are not pasting all the
values.

Hope this helps.

Pete

On Oct 11, 1:31 pm, Sunnyskies
wrote:
Afternoon Pete,

I inserted the script you provided between the lines:
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
and

Set wb = ActiveWorkbook

And unfortunately still get the #REF! on the new worksheet once I had opened
it up.

Any other possible solution?



"Pete_UK" wrote:
After your paste special | values line, I think you will need this:


Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
SkipBlanks:= False, Transpose:=False
Application.CutCopyMode = False


Hope this helps.


Pete


On Oct 11, 9:54 am, Sunnyskies
wrote:
Morning from a overcast South Africa,


I have this macro that is supposed to copy a worksheet, paste the values and
formats onto a new worksheet and then send the new worksheet via e-mail.


Can you please identify why when copy and pasted onto the new worksheet ,the
calculated cells all have #REF!.


Here is the macro that is causing the problem.


Sub EMail()
'Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Unprotect Password:="Drivers"
Next n
Application.ScreenUpdating = True
'End Sub


Dim wb As Workbook
Application.ScreenUpdating = False
ActiveSheet.Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set wb = ActiveWorkbook
With wb
.SendMail "", _
ThisWorkbook.Names("Spreadsheet_Name").RefersToRan ge.Value
'Range ("E2") & " Payroll MonthEnd figures"
'"This is the Subject line"
.Close False
End With
Application.ScreenUpdating = True
'End Sub


'Sub ProtectAllSheets()
Application.ScreenUpdating = False
'Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="Drivers"
Next n
Application.ScreenUpdating = True
End Sub


Waiting in anticipation.- 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
Formulas don't work after copy/paste from Lotus 1-2-3 97 (Excel 20 Bardur Excel Discussion (Misc queries) 1 February 1st 07 05:02 PM
copy paste between two instances does not work [email protected] Excel Discussion (Misc queries) 5 August 3rd 06 01:06 AM
Copy and paste between windows in excel 2003 will not work april g. Excel Worksheet Functions 0 March 2nd 06 07:35 PM
Copy paste in excel dont work properly [email protected] Excel Discussion (Misc queries) 0 December 30th 05 09:57 AM
Data validation does not seem to work with copy/paste LAF Excel Discussion (Misc queries) 1 September 15th 05 09:31 PM


All times are GMT +1. The time now is 10:20 AM.

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"