event code error when trying to copy and paste

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hi

Hope all your loved ones are safe
This event code works except for when it tries to copy from the cell above
It gives me an error and wants me to debug
VBA Code:
ActiveCell.Offset(-1, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
I put notes in to show what I’m trying to do
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
' enter date in A move 2 cells to right
If Not Intersect(Target, Range("a40:a300")) Is Nothing Then
Target.Offset(0, 2).Select
End If
' enter date in C move 2 cells to right
If Not Intersect(Target, Range("c50:c600")) Is Nothing Then
Target.Offset(0, 2).Select
End If
' enter start reading in E move 1 cell to righ
If Not Intersect(Target, Range("e40:e300")) Is Nothing Then
Target.Offset(0, 1).Select
End If
' enter end date in F move 3 cells to right
If Not Intersect(Target, Range("f40:f600")) Is Nothing Then
Target.Offset(0, 3).Select
End If
' enter amount in I and go back to a and drop one line
If Not Intersect(Target, Range("i40:i300")) Is Nothing Then
Target.Offset(1, -8).Select
End If
' copy from 1 cell above
'ActiveCell.Offset(-1, 0).Range("A1").Select
' Application.CutCopyMode = False
' Selection.Copy
' ActiveCell.Offset(1, 0).Range("A1").Select
' ActiveSheet.Paste
' enter date in A move 2 cells to right
If Not Intersect(Target, Range("a40:a300")) Is Nothing Then
Target.Offset(0, 2).Select
End If
' enter date in C move 2 cells to right
If Not Intersect(Target, Range("c40:c600")) Is Nothing Then
Target.Offset(0, 2).Select
End If
' copy from 1 cell above
'ActiveCell.Offset(-1, 0).Range("A1").Select
'Application.CutCopyMode = False
' Selection.Copy
' ActiveCell.Offset(1, 0).Range("A1").Select
' ActiveSheet.Paste
' enter start reading in E move 1 cell to right
If Not Intersect(Target, Range("e40:e300")) Is Nothing Then
Target.Offset(0, 1).Select
End If
' enter end date in F move 3 cells to right
If Not Intersect(Target, Range("f40:f600")) Is Nothing Then
Target.Offset(0, 3).Select
End If
' enter amount in I and go back to a and drop one line
If Not Intersect(Target, Range("i40:i300")) Is Nothing Then
Target.Offset(1, -8).Select
End If
‘ that will end any data entry
End Sub


mike
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Not sure what you're doing, but replace this:
ActiveCell.Offset(-1, 0).Range("A1").Select Application.CutCopyMode = False Selection.Copy ActiveCell.Offset(1, 0).Range("A1").Select ActiveSheet.Paste

by this:
VBA Code:
    Selection.Offset(-1, 0).Copy Target
 
Upvote 0
Hi GWteB
Using a Change Event marco...
1) After I enter something in A (a date), the cursor will move 2 cells to the right (C)
2) Then after I enter something in C, ( a another date). the cursor will move 2 cells to the right (E)
3) Then after I enter something in E , (a number), the cursor will move 1 cell to the right (F)
4) Then after I enter something in F, (a number) the cursor will move 3 cells to the right (I)
4) Then after I enter something in I (a number), the cursor will move 8 cells to the LEFT (back to A) and drop down 1 cell
This works exactly how I want it to.
What I'm trying to do is have the macro copy what I just put in A after the cursor moves to the empty A (#4)
then do #2 and again copy what is in the cell above (which is C),
then # 3 and # 4.
then end.
I'm having problems with the copying.
The macro seems go into debug mode and excel freezes. I have to reboot excel
I tried to change my copy macro to your suggestion. but it still doesn't work


mike
 
Upvote 0
As an edit
I'm using 1 line A to I
then dropping down 1 line and using A to I again on the new line

mike
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top