Force data entry in next empty row

kungsleden

New Member
Joined
Apr 12, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,
I just registered. Quite new to VBA but have used Excel for quite a few years.
I am working on a log sheet for a piece of equipment. When a user uses the log sheet, I would like them to be able to enter data only in the first blank row. At the moment, they can enter data in any of the empty rows.

Regards,

Christophe
 
Most codes you need to turn the protection off before the code and back on immediately afterwards if you are interacting with the cells or use userinterfaceonly when protecting the sheet.

 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
HI, @kungsleden
Try this:
I assumed data entry must start at the first column .
It use "Worksheet_Change" event.
Change "Table1" to suit.
Try it without the sheet protection first, if it works then you can amend the code to include turning off-on the sheet protection.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo skip:

With ActiveSheet.ListObjects("Table1")
    If Not Intersect(Target, .Range) Is Nothing Then
       If .Range.Cells(1).End(xlDown).Row < Target.Row Then

        Application.EnableEvents = False
            Target.ClearContents
            .Range.Cells(1).End(xlDown).Offset(1).Activate
        Application.EnableEvents = True
        End If

    End If
End With
Exit Sub

skip:
Application.EnableEvents = True
MsgBox "Error number " & Err.Number & " : " & Err.Description
End Sub
 
Upvote 0
Thank you Akuini, I will try that.

I joined a few hours ago, and very pleased to get suggestions to my question very quickly. A lot to learn. (y)
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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