ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Cut-And-Paste Text (https://www.excelbanter.com/excel-programming/324069-macro-cut-paste-text.html)

whyloo

Macro to Cut-And-Paste Text
 
Hi,

I'm creating a timeline which has special formatting for each new activity.
I want to create a macro that will insert a new activity at the cursor every
time I run it. So far, I have:

Sub Activity()
'
' Activity Macro
' This macro adds a new activity.
'
' Keyboard Shortcut: Ctrl+Shift+A
'
ActiveWindow.SmallScroll Down:=-36
Rows("9:10").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=30
Rows("42:42").Select
ActiveSheet.Paste
Rows("42:42").Select
Application.CutCopyMode = False
End Sub

But, what this does is paste the text from Rows 9 and 10 always into Rows
42. How can I write the macro so it will paste the text into whatever row is
active?

Thanks!


Jim Thomlinson[_3_]

Macro to Cut-And-Paste Text
 
Try this...

Sub Activity()
'
' Activity Macro
' This macro adds a new activity.
'
' Keyboard Shortcut: Ctrl+Shift+A
'
Rows("9:10").Copy ActiveCell.EntireRow

Application.CutCopyMode = False
End Sub

HTH

"whyloo" wrote:

Hi,

I'm creating a timeline which has special formatting for each new activity.
I want to create a macro that will insert a new activity at the cursor every
time I run it. So far, I have:

Sub Activity()
'
' Activity Macro
' This macro adds a new activity.
'
' Keyboard Shortcut: Ctrl+Shift+A
'
ActiveWindow.SmallScroll Down:=-36
Rows("9:10").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=30
Rows("42:42").Select
ActiveSheet.Paste
Rows("42:42").Select
Application.CutCopyMode = False
End Sub

But, what this does is paste the text from Rows 9 and 10 always into Rows
42. How can I write the macro so it will paste the text into whatever row is
active?

Thanks!



All times are GMT +1. The time now is 04:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com