First empty cell in selected row

ACTInstructor

New Member
Joined
Feb 3, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Good Day -
Having a hard time getting my code right. What I would like to do is the following:
Click in a given cell, and using THAT row, find the 1st empty cell and insert the current date. The date part is easy enough, its finding the 1st empty cell in the row i clicked on.


Screenshot 2023-02-03 114801.png



The code I've been toying with in various manners is:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim xRow As Integer
Dim xCol As String

xRow = Target.Row
xCol = Target.Column

If Not Intersect(Range(Selection.Address), Target) Is Nothing Then

'Rows(xRow).End(xlToRight).Offset(0, 1).Select
'Range (Selection.Address), Target.End(xlToRight).Offset(0, 1).Select

End If

End Sub

any help or guidance is highly appreciated.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I would do that by usingthe BeforeDoubleclick event instead of the worksheet selection change because otherwise you are going to get dates every time you click anywhere
try this:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
rowno = Target.Row
lastcol = Cells(rowno, Columns.Count).End(xlToLeft).Column + 1
Cells(rowno, lastcol) = Date
End Sub
obviously double click to getthe date inserted
 
Upvote 0
Solution
That worked just fine. Think I'll fine tune it to select the cell with the new date when its updated, just in case a manual override is needed.
I did switch it back over to selectionchange as the doubleclick exposed the formulas where the names are.

Many thanks for your time and expertise.
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,222
Members
453,024
Latest member
Wingit77

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