VB Help

jayjaysb

Board Regular
Joined
Nov 16, 2011
Messages
204
Hi all,

I have created 2 tabs Data and Form, Data Entry Form. With Name, Date, Item No, Outcome (dropdown) and Comment. Along with Save and Reset Buttons.

Could someone please help with VB for me. Thanks JJSB
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
.
Here is a small database project to review. Study the code. It has everything you are seeking but the existing code needs
to be edited to fit your specific project. (i.e, You will need to use your own variable names and also expand on the existing
code to include all the fields you are using.)

This example uses a UserForm for the data input.

Code:
Option Explicit
Private Sub btnCancel_Click()
    Unload Me
End Sub


Private Sub btnOK_Click()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Dim newRow As Long
    
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
    
    'The next two lines can be expanded as many times as needed for all the entry fields in your project
    
    ws.Cells(newRow, 1).Value = Me.txtFirstName.Value
    ws.Cells(newRow, 2).Value = Me.txtSurname.Value
    
End Sub
Sub CommandButton1_Click()
    Selection.EntireRow.Delete
End Sub

Download file : https://www.amazon.com/clouddrive/share/1mJIn9XSkerqNOlNHHP7T0lT15OoyeoKfIGlGZX3j2I
 
Upvote 0
deleted by Yongle
 
Last edited:
Upvote 0
Many thanks, JJSB

.
Here is a small database project to review. Study the code. It has everything you are seeking but the existing code needs
to be edited to fit your specific project. (i.e, You will need to use your own variable names and also expand on the existing
code to include all the fields you are using.)

This example uses a UserForm for the data input.

Code:
Option Explicit
Private Sub btnCancel_Click()
    Unload Me
End Sub


Private Sub btnOK_Click()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Dim newRow As Long
    
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
    
    'The next two lines can be expanded as many times as needed for all the entry fields in your project
    
    ws.Cells(newRow, 1).Value = Me.txtFirstName.Value
    ws.Cells(newRow, 2).Value = Me.txtSurname.Value
    
End Sub
Sub CommandButton1_Click()
    Selection.EntireRow.Delete
End Sub

Download file : https://www.amazon.com/clouddrive/share/1mJIn9XSkerqNOlNHHP7T0lT15OoyeoKfIGlGZX3j2I
 
Upvote 0
Hi Logit, If someone completes the fields, then realises the data is wrong, then they would hit reset button to clear the data. Thanks
 
Upvote 0
.
Using the example project :

Code:
Sub ClrFields()
     Me.txtFirstName.Value = ""
     Me.TxtSurname.Value = ""
     'add more fields ...
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

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