ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Active cell position for macro (https://www.excelbanter.com/excel-worksheet-functions/159334-active-cell-position-macro.html)

MechEng

Active cell position for macro
 
I am running a macro to add rows or remove rows assigned to a form button.
The problem is if the active cell is moved from the last blank row the marco
won't run.

Is it possible to have the macro alway return the cursor to the required
active cell before it runs?

Sandy Mann

Active cell position for macro
 
May have been better if you had posed some of yout code but try something
like:

ActiveCell.End(xlUp).Offset(1, 0).Select

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"MechEng" wrote in message
...
I am running a macro to add rows or remove rows assigned to a form button.
The problem is if the active cell is moved from the last blank row the
marco
won't run.

Is it possible to have the macro alway return the cursor to the required
active cell before it runs?




Gord Dibben

Active cell position for macro
 
Without seeing your code it is hard to say why your macro won't run if
activecell is not in last blank row.

This will move the cursor to last blank cell in column A

Sub foo()
Dim rcell As Range
Set rcell = ActiveSheet.Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
Application.Goto Reference:=rcell
MsgBox "Activecell is" & rcell.Address
End Sub


Gord Dibben MS Excel MVP

On Sat, 22 Sep 2007 12:36:00 -0700, MechEng
wrote:

I am running a macro to add rows or remove rows assigned to a form button.
The problem is if the active cell is moved from the last blank row the marco
won't run.

Is it possible to have the macro alway return the cursor to the required
active cell before it runs?



MechEng

Active cell position for macro
 
Thank you both. It is working great now.
I appreciate the help.

Dan

"Gord Dibben" wrote:

Without seeing your code it is hard to say why your macro won't run if
activecell is not in last blank row.

This will move the cursor to last blank cell in column A

Sub foo()
Dim rcell As Range
Set rcell = ActiveSheet.Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
Application.Goto Reference:=rcell
MsgBox "Activecell is" & rcell.Address
End Sub


Gord Dibben MS Excel MVP

On Sat, 22 Sep 2007 12:36:00 -0700, MechEng
wrote:

I am running a macro to add rows or remove rows assigned to a form button.
The problem is if the active cell is moved from the last blank row the marco
won't run.

Is it possible to have the macro alway return the cursor to the required
active cell before it runs?





All times are GMT +1. The time now is 11:25 AM.

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