Copy Paste Delete Macro ?

sqex

New Member
Joined
Nov 22, 2005
Messages
19
HI Guys.

Im look for a way that when a button is clicked withing excel it will copy all data from certain cells to another sheet.

eg


A1 A2 A3

Data 1 Date Button - that copies


Sheet 2


A1 A2 A3

Data 1 copy Date copy Completed


I then need it to delete the orginal entry and just leave the word completed

IF anyone could help me out on this one i would be very very greatfull

Regards

sqex
 
iv changed the macro to a new one i found worked, but i seem to be having some problems with it

for example it will not work on all of the other buttons i have assigned it to even when i change the values ti what they should be.

this is the macro below

Sub Row2()
'
' Row2 Macro
' Macro recorded 11/25/2005 by luceyj
'

'
Range("B12").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B6").Select
ActiveSheet.Paste
Sheets("Monday").Select
Range("B12").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "COL"
Range("B12").Select
Selection.ClearContents
Range("E12").Select
Selection.ClearContents
Range("I12").Select
Selection.ClearContents
End Sub

This works for row 2 but when i use it for row 3 and change the values to mach row 3. it comes back with an error and when i go to debug it highlights the activesheet.paste function ?

any ideas
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I'm sorry but I'm left with more questions than answers at this point.
I don't see where this does anything with row 2 at all.
The only cell references you have here are all for row 12 and one for row 6.

I've taken the liberty of editing your code to avoid all those selections as they're mostly not necessary and just slows down the code. (The macro recorder records a lot of stuff you really don't need.)
I assumed you want to be left in Sheet "Monday" after the code runs so I left that one in.
All of the actions in the macro you recorded can be carried out (and faster) with only 5 lines of code. (4 if you don't want to be left in sheet "Monday".)

Below is an explanation of what I mean. I've commented out each section of the recorded code and shown how it can be done with a line or two for each section.
Code:
Sub Row2Demo()
'Range("B12").Select
'Selection.Copy
'Sheets("Sheet1").Select
'Range("B6").Select
'ActiveSheet.Paste
Range("B12").Copy Sheets("Sheet1").Range("B6")
Application.CutCopyMode = False

Sheets("Monday").Select
'Range("B12").Select
'ActiveCell.FormulaR1C1 = "COL"
Range("B12").Value = "COL"

'***Do you really want to clear B12, where you just put "COL"???***
'Range("B12").Select
'Selection.ClearContents
'Range("E12").Select
'Selection.ClearContents
'Range("I12").Select
'Selection.ClearContents
Range("B12, E12, I12").ClearContents
End Sub
This is how the code would look all by itself...
Code:
Sub Row2Demo2()
Range("B12").Copy Sheets("Sheet1").Range("B6")
Application.CutCopyMode = False
Sheets("Monday").Select
Range("B12").Value = "COL"
'***Do you really want to clear B12, where you just put "COL"???***
Range("B12, E12, I12").ClearContents
End Sub
Another point in question is if you really want to clear the contents of sheet "Monday" cell B12 right after inputting "COL" in that cell.

Now back to your question, :biggrin: you want to change this to run on different row(s)? What exactly are you looking to have it do?
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,017
Members
449,280
Latest member
Miahr

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