Allow Data Entry into Excel Worksheet Via User Form Only

How to Allow data Entry into an Excel Worksheet Via User-Form or Macro Only.

Here’s the complete VBA code:

Option Explicit

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdTransfer_Click()
Dim erow As Long
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1) = txtCustomerName
Cells(erow, 2) = txtMobile
End Sub

Private Sub Workbook_Open()
ActiveWorkbook.Sheets(“Sheet1″).Protect Password:=”macr0@entrY”, userinterfaceonly:=True

‘we can also use the line of code below

‘ThisWorkbook.Sheets(“Sheet1″).Protect Password:=”macr0@entrY”, userinterfaceonly:=True

UserForm1.Show
End Sub

Private Sub cmdDisplayUserForm_Click()
UserForm1.Show
End Sub

Further Reading:

Worksheet.Protect method (Excel)

Advanced User-Form

Published by

Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

One thought on “Allow Data Entry into Excel Worksheet Via User Form Only”

  1. Thank you for sharing these wonderful features of VBA.

    In the same program of UserForm if I want to restrict duplicate entries who can I do it.

    A user shouldn’t be allowed to enter his details twice and should prompt an error message “Data already exists”.

    Regards,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.