LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,090
Default error when running cut & paste macro

The problem is the placement of the 2 macros. The first one belongs in a
regular module. If it was working before, then you have it in the right
place. Leave it there.
The second macro is what is called a "sheet macro" or a "sheet event
macro". It has to go into a different type of module, called a "sheet
module". Every sheet has a sheet module of its own. This type of macro
fires automatically upon the occurrence of some event in that sheet. In
this case, the event is the selection of any cell in the entire sheet. Is
that what you wanted with this macro? You don't have any code in that macro
to narrow down the range in which a selection will result in some action
being taken. Right now you will get the action with any cell being
selected. Any cell in the entire sheet! The action is adding borders and
colors. Exactly what did you want this second macro to do? HTH Otto
PS: To access the sheet module of a sheet, right-click on the sheet tab,
select View Code. There is the sheet module for that sheet.
"Redskinsfan" wrote in message
...
I had the following macro workin fine prior to adding a macro to the sheet.
here's the macro im having problems with i get the error message on
ActiveSheet.paste..

below this macro i will add the new macro added to sheet which started
causing for the macro above to stop working.

Sub New_Trade()
'
' New_Trade Macro
' Macro recorded 8/2/2006 by Parsons User
'
ActiveSheet.Protect UserInterfaceOnly:=True
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(-2, 0).Rows("1:1").EntireRow.Select
Selection.Copy
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Range("A1:D1").Select
Application.CutCopyMode = False
End Sub

Below this is the macro i added to the whole sheet which now is causing my
other macros to give me the error on the paste line to stop..

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Protect UserInterfaceOnly:=True
Cells.FormatConditions.Delete
With Target
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
End With
.FormatConditions(1).Interior.ColorIndex = 19
End With

End Sub

Im a newbie with macros and most of these i have taken from samples so
please when explaining would apreciate if done in simple terms.. Thanks in
advance



 
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 - select and paste Rashid Excel Worksheet Functions 1 May 21st 06 09:54 PM
Macro to run on the "Active Sheet" David P. Excel Discussion (Misc queries) 8 April 11th 06 07:42 PM
Need a macro to Copy a selection and paste into a new email. Koolmist Excel Discussion (Misc queries) 3 February 20th 06 04:48 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Copy Paste macro GWB Direct Excel Discussion (Misc queries) 2 May 9th 05 03:31 PM


All times are GMT +1. The time now is 10:02 PM.

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"