Help with Macro

R

RoadKing

Good evening:

Thanks in advance for your help
John
______________________________________________________

Sub MoveData()
'
' MoveData Macro
' Macro recorded 8/25/2007 by John Donadio
'
' Keyboard Shortcut: Ctrl+z
'
Range("A12:L12").Select
Selection.Copy
Sheets("Activity").Select
Range("A1").Select
Selection.End(xlDown).Select
Range("A26").Select ** I need this to go to the a blank
row rather than returning to A26**
ActiveSheet.Paste
Range("A1").Select
Sheets("Data Sheet").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub
 
D

Dave Peterson

Option Explicit
Sub MoveData2()

Dim FromRng as range
Dim ToRng as range

with workSheets("Data Sheet")
set fromrng = .range("A12:L12")
end with

with worksheets("Activity")
set torng = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

fromrng.copy _
destination:=torng

fromrng.clearcontents

End Sub

And I don't think I'd use ctrl-z as my keyboard shortcut. That's the shortcut
for Edit|Undo.

How about ctrl-shift-Z.
 
G

Gord Dibben

This will find the first blank in column A

Sub MoveData()
Sheets("Data Sheet").Select
ActiveSheet.Range("A12:L12").Copy Destination:= _
Sheets("Activity").Cells.End(xlDown) _
.Offset(1, 0)
Range("A1").ClearContents
End Sub

No need for all that selecting, copying and pasting that Excel records.

To find the first blank cell at the bottom of the column and copy to that range
use this......

Sub MoveData()
Sheets("Data Sheet").Select
ActiveSheet.Range("A12:L12").Copy Destination:= _
Sheets("Activity").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
Range("A1").ClearContents
End Sub



Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top