Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Shouldn't this work?

Sub KillIt()
'
' After you have copied a range(i.e., pivot table), this macro
' is used to paste it in inert form, for distribution
' to non-technical users.

If Application.CutCopyMode = True Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else: MsgBox ("You have to copy, before you can paste")
End If
End Sub

When I run this, even after copying a range, it still defaults to the ELSE
section.

The purpose of the macro, is to PASTE, and I want to make sure the user has
copied something, before they run the macro.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Shouldn't this work?

I don't think "Else" should be followed by a colon ":".

Paul

"Jonathan Cooper" wrote in
message ...
Sub KillIt()
'
' After you have copied a range(i.e., pivot table), this macro
' is used to paste it in inert form, for distribution
' to non-technical users.

If Application.CutCopyMode = True Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else: MsgBox ("You have to copy, before you can paste")
End If
End Sub

When I run this, even after copying a range, it still defaults to the ELSE
section.

The purpose of the macro, is to PASTE, and I want to make sure the user
has
copied something, before they run the macro.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Shouldn't this work?

Actually the colon is an old and little-used syntax for putting multiple
statements on one line, e.g.

For i = 1 To 3: Debug.Print i: Next i

Try this to fix your problem:

If Application.CutCopyMode Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else
MsgBox ("You have to copy, before you can paste")
End If

"PCLIVE" wrote:

I don't think "Else" should be followed by a colon ":".

Paul

"Jonathan Cooper" wrote in
message ...
Sub KillIt()
'
' After you have copied a range(i.e., pivot table), this macro
' is used to paste it in inert form, for distribution
' to non-technical users.

If Application.CutCopyMode = True Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else: MsgBox ("You have to copy, before you can paste")
End If
End Sub

When I run this, even after copying a range, it still defaults to the ELSE
section.

The purpose of the macro, is to PASTE, and I want to make sure the user
has
copied something, before they run the macro.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Shouldn't this work?

"Jonathan Cooper" wrote in
message ...
Sub KillIt()
'
' After you have copied a range(i.e., pivot table), this macro
' is used to paste it in inert form, for distribution
' to non-technical users.

If Application.CutCopyMode = True Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else: MsgBox ("You have to copy, before you can paste")
End If
End Sub

When I run this, even after copying a range, it still defaults to the ELSE
section.

The purpose of the macro, is to PASTE, and I want to make sure the user
has
copied something, before they run the macro.


Don't think CutCopyMode really returns True like that, rather xlCopy,
xlCut or False, so your code should be changed to check for False
instead, and moving the paste code to the else branch.

/impslayer, aka Birger Johansson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Shouldn't this work?

That appears to have done the trick. Thanks.

"Charlie" wrote:

Actually the colon is an old and little-used syntax for putting multiple
statements on one line, e.g.

For i = 1 To 3: Debug.Print i: Next i

Try this to fix your problem:

If Application.CutCopyMode Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else
MsgBox ("You have to copy, before you can paste")
End If

"PCLIVE" wrote:

I don't think "Else" should be followed by a colon ":".

Paul

"Jonathan Cooper" wrote in
message ...
Sub KillIt()
'
' After you have copied a range(i.e., pivot table), this macro
' is used to paste it in inert form, for distribution
' to non-technical users.

If Application.CutCopyMode = True Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else: MsgBox ("You have to copy, before you can paste")
End If
End Sub

When I run this, even after copying a range, it still defaults to the ELSE
section.

The purpose of the macro, is to PASTE, and I want to make sure the user
has
copied something, before they run the macro.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Shouldn't this work?

VBA put that in there automatically. I deleted it, and VBA put it back in
there again.

"PCLIVE" wrote:

I don't think "Else" should be followed by a colon ":".

Paul

"Jonathan Cooper" wrote in
message ...
Sub KillIt()
'
' After you have copied a range(i.e., pivot table), this macro
' is used to paste it in inert form, for distribution
' to non-technical users.

If Application.CutCopyMode = True Then
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
Else: MsgBox ("You have to copy, before you can paste")
End If
End Sub

When I run this, even after copying a range, it still defaults to the ELSE
section.

The purpose of the macro, is to PASTE, and I want to make sure the user
has
copied something, before they run the macro.




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
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
how can i automatically generate work order numbers from work orde rob h Excel Discussion (Misc queries) 1 July 13th 09 07:59 PM
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM


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