Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate current cell 1

Status
Not open for further replies.

rcarlyle

Technical User
Mar 27, 2007
21
0
0
I am trying to write a macro which selects the row of the cell I am currently in and inserts a blank row. I have tried using active.cell, but it keeps selecting A1 as the active cell. I know that this is horribly basic, but I just can't think of what I need to do to make the cell I am on the active cell. Help please.
 




Hi,

Please post your code.

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
Sub InsertRow()
'
' InsertRow Macro
' Macro recorded 20/07/2007 by Morinda, Inc.
'
' Keyboard Shortcut: Ctrl+i
'
ActiveCell.Activate
Rows.EntireRow(1).Select
Selection.Insert Shift:=xlDown
End Sub
 



I avoid the activate and select methods as much as possible...
Code:
ActiveCell.EntireRow.Insert Shift:=xlDown
I also try to avoid INSERT and DELETE, FYI.

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
Because it tends to mess up named ranges and/or formulae if not treated carefully. It is normally better to enter data at the end of a block and then re-sort rather than to insert a new line into the middle of a block of data

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 




Geoff stated it exactly as I would have.

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
Thanks for your help guys, much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top