Macro to move to next cell

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,568
Office Version
  1. 2021
Platform
  1. Windows
I have a list of file names in Col A. Before running my macro for the first time, I select Cell A1, and it inserts a comment in C1

Once the macro has run I want it to the cursor to be on A2, then after running the macro select A3 etc


The code that inserts the comment in Col C is as follows:


Code:
 rng.Offset(, 2) = "workbook mailed"

It tried using the code below, but get a run time error

Code:
 ActiveCell.Offset(1, -2).Select

It would be appreciated if you someone could kindly assist me
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Place this code in the Worksheet_Change event

Code:
Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 Then
        Target.Offset(0, 2) = "Workbook Mailed"
        Target.Offset(1, 0).Select
    End If


End Sub
 
Upvote 0
Your first code is not using "Select" so you are actually still on A1, so would only require
activecell.offset(1).select

If you are just running through the cells in Column A, possible looping through the cells.
Code:
Sub Button1_Click()
    Dim rng As Range, LstRw As Long, c As Range

    LstRw = Cells(Rows.Count, "A").End(xlUp).Row
    Set rng = Range("A1:A" & LstRw)

    For Each c In rng.Cells
        c.Offset(, 2) = "workbook mailed"
    Next c


End Sub
 
Last edited:
Upvote 0
Thanks for the help Guys

What I want to do is move to A2 after emailing the file, then A3 , A4 etc after running the macro each time
 
Upvote 0
Thanks Dave , I used ActiveCell.Offset(1).Select and it works perfectly
 
Upvote 0

Forum statistics

Threads
1,215,787
Messages
6,126,897
Members
449,347
Latest member
Macro_learner

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top