Where am I going wrong?


G

Guest

Help - trying to Insert Row using CTRL + L (Need to unhide the inserteed row
if that makes sense???)

Sub NewLine()
'
' NewLine Macro
' Macro recorded 31/03/2006 by XXX
'
' Keyboard Shortcut: Ctrl+l
'
ActiveWindow.ScrollRow = 21
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 19
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 17
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 12
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 10
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
Rows("16:16").Select
Application.CutCopyMode = False
Selection.Copy
Range("A22").Select
Selection.End(xlDown).Select
Selection.Insert Shift:=x2Down
Selection.EntireRow.Hidden = False

End Sub
 
Ad

Advertisements

Ad

Advertisements

C

Chip Pearson

You don't need to Select the row.

ActiveCell.EntireRow.Insert shift:=xlShiftDown

It is very rare that you need to Select anything in VBA. Your
code will be considerably faster if you don't select an object,
but instead operate on the object itself.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


message
 

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