How do I write a Macro to Move cursor to next blank cell in a specific row, say row 2

kalil

New Member
Joined
Sep 21, 2022
Messages
5
Office Version
  1. 2003 or older
Platform
  1. Windows
How do I write a Macro to Move cursor to next blank cell in a specific row, say row 2
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
how about
Range("2" & worksheets(1).columns.count).end(xlRt).Offset(0,1).Select
 
Upvote 0
See if one of these 2 work for you.

VBA Code:
' Using the Active Cell
Sub NextBlankCellOnRow()

    Dim rCell As Range
    Dim ws As Worksheet
    
    Set ws = ActiveSheet
    Set rCell = ActiveCell
    
    If rCell.Offset(0, 1) = "" Then
        rCell.Offset(0, 1).Select
    Else
        rCell.End(xlToRight).Offset(0, 1).Select
    End If
    
End Sub

VBA Code:
' Specifying the starting cell
Sub NextBlankCellOnRow_SpecifiedCell()

    Dim rCell As Range
    Dim ws As Worksheet
    
    Set ws = Worksheets(1)
    Set rCell = ws.Cells(2, "A")
    
    If rCell.Offset(0, 1) = "" Then
        rCell.Offset(0, 1).Select
    Else
        rCell.End(xlToRight).Offset(0, 1).Select
    End If
    
End Sub
 
Upvote 0
Thanks Alex, u are my champion, hero and star indeed
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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