Anda di halaman 1dari 17

We'd like to show you notifications for the latest

news and updates.

COURSES TUTORIALS CORPORATE TRAINING LOGIN SIGN UP

NO THANKS ALLOW

EXCEL FORMULAS PIVOT TABLE POWER BI SHORTCUTS VBA & MACROS

How to Update and Delete Using


Excel VBA Userform ? | VBA
Userform
i YODA LEARNING m TUTORIALS, VBA & MACROS

 EXCEL, EXCEL VBA USEFORM, UPDATE & DELETE, USEFORM, VBA USEFORM v 0

Learn How to Update and Delete Using Excel VBA Userform? Download Tips &
Tricks
It’s useful for making a task easy in business areas like Banking Record,
Personal Finance, Stock Reporting, Recordkeeping, Automate Training room 150+ Excel

booking, Hotel Room booking, Car Booking, booking IT resources and Shortcuts

approval of business expenses such as refreshments, conveyance, stationery 200+ Excel

etc. Formulas PDF


150+
PowerPoint
Multi Page User Forms VBA - Employee Database | In… Shortcuts
15+ Excel Tips
& Tricks
Clyde  from London
Enrolled Excel VBA Course
⚡ few minutes ago
Related Blogs
200+ MS Excel
We'd like to show you notifications for the latest
Shortcuts
news and updates.
Top Excel
Download Sample Files
Formulas &
This technique will help User access the data in the VBA Userform only and
NO THANKS ALLOW Function
then if he\she wants to update any info, he\she can update the same by
Pivot Table
pressing “UPDATE” button and the same records will be updated in the sheet
Complete
(Database). Similarly, User can delete the records if required.
Tutorial

Learn Excel Basic –


Advanced Excel
VBA 
Flash fill
(Beginner
Remove
To Duplicates
Advanced) Wrap Text in
Excel
If you want OFFSet
to be a Function
master at Create Sparkline

Excel VBA Programming language for Excel 2007, then our Excel Pivot Table
Slicers
VBA macros tutorials will make it easier for you to access it in
Remove blank
applications such as Microso O ice. Come create your own
cells
Macros and rule in excel.
AutoSum in
Excel
JOIN NOW

Tags
Table of Contents 

Let’ start with the recordset which


10 NINJA TIPS

contains a lot of info like below.


ABS FUNCTION

ADVANCED EXCEL

Clyde  from London


Enrolled Excel VBA Course AND FUNCTION
⚡ few minutes ago
(Picture 1)
AVERAGEIF
FUNCTION
First, Create a VBA UserForm like one in below picture.
First, Create a VBA UserForm like one in below picture.

We'd like to show you notifications for the latest CHAR FORMULA

news and updates.


CONDITIONAL
FORMATTING

NO THANKS ALLOW
CONVERT EXCEL TO
PDF

COPY TEXT FROM


IMAGE

DEGREE SYMBOL

EXCEL

EXCEL ADVANCED
FILTERS

(Picture 2) – VBA Userform EXCEL CHART HACK

Steps to create VBA UserForm are


EXCEL FORMULA

mentioned below: EXCEL FORMULAS

EXCEL FUNCTION
1. Press Alt + F11.
2. Click Insert, User form. If the Toolbox does not appear automatically, EXCEL MACROS

click View, Toolbox. Your screen should be set up as below.


EXCEL NINJA

EXCEL SHORTCUTS

EXCEL SPREADSHEET

EXCEL TIPS

EXCEL TIPS AND


TRICKS

Clyde  from London FINANCIAL MODEL


Enrolled Excel VBA Course
3. Add the controls
⚡ few listed in the table below. Once this has been
minutes ago
HOW TO TYPE
completed, the result should be consistent with the picture of the DEGREE SYMBOL

Userform shown earlier For example create a text box control by


Userform shown earlier.For example, create a text box control by
INDIRECT FUNCTION
clicking on TextBox from theWe'd like to
Toolbox. show
Next, youyou
cannotifications foronthe latest
drag a text box
news and updates.
the Userform.4. Change the names and captions of the controls INSERT BLANK ROWS
WHEN VALUE
according to the table above. Names are used in the Excel VBA code. CHANGES IN EXCEL

Captions are those that appear on your screen. NO


It is THANKS
good practice to ALLOW
KEYBOARD
change the names of controls. This will make your code easier to read. SHORTCUTS

To change the names and captions of the controls, right click on VBA
LEARN CLIPBOARD
Userform and click on each control.
MACRO TO CONVERT
EXCEL

MERGE EXCEL FILES

MICROSOFT
ONENOTE

MS ONENOTE
 

MS WORD
Recommended:
MS WORD TRICKS
Update and Delete Using Excel VBA Userform, Remove
Password From Excel Using Excel VBA (Coding) or you can learn PERCENTILE

much more related tips & tricks. Learn More


PIVOT TABLE

Create Dynamic Graphs & Excel Presentation. Also, Learn How PIVOT TABLE
TECHNIQUES
to create Data Analytic Chart & Graph. Learn More
PPT TIPS

QUARTILE

REMOVE DUPLICATE
IN EXCEL

  REMOVE PASSWORD
Clyde  from London
Enrolled Excel VBA Course
Once you are done creating a VBA user form which looks like UserForm
⚡ few minutes ago
SPECIAL TABLE
TRICKS
shown earlier with another 2 command buttons; “Update” and “Delete”. This
VBA Userform will pull up all the information from the sheet when I will
TIME
choose any value in “SL No” in UserForm.
We'd like to show you notifications for the latest UNPROTECT EXCEL
news
Every time you choose the “SL No” and
from theupdates.
drop down the value for the
other fields will be changed. First click on the drop down box in UserForm WORD

next to “SL No” to set the row source property, see image below for your
NO THANKS ALLOW
reference.

Search... 

Related Tutorials

How to use Ceiling


Function in Excel
JANUARY 30, 2019
You should set a name to Object in VBA Userform like I did by naming the “SL
No” drop down box as cmbslno. How to use Char
Function in Excel
JANUARY 28, 2019

Text To Column in
Excel | Split Cells
JANUARY 4, 2019

Pivot Tables

(Picture 3) – VBA Userform (Complete


Guidelines)
  DECEMBER 27, 2018

Now if you choose any value from the box then the value of the other boxes Power Bi Dax
will auto-populated. To do so I have applied simple Vlookup formula using Deduplication Based
VBA Code, Please refer the codes. On Column
DECEMBER 17, 2018

We have already covered how to create userforms


and how toExcel
set VBAthe
Coursepermission in the sheet using
Clyde  from London Special Character
Enrolled
Symbol List with
⚡ few minutes ago
VBA. Shortcodes in Excel
DECEMBER 15, 2018
Now double click on the box (cmbslno) and paste the below
d
code. How to use
We'd like to show you notifications for the latest
AVERAGEIFS
news and updates.
FUNCTION in Excel
Dim SLNo As Integer
DECEMBER 10, 2018

If Me.cmbslno.Value = “” Then NO THANKS ALLOW


How to use

MsgBox “SL No Can Not be Blank!!!”, vbExclamation, “SL No” AVERAGEIF


FUNCTION
Exit Sub DECEMBER 10, 2018

End If How to use ABS


Function in Excel
SLNo = cmbslno.Value DECEMBER 10, 2018

On Error Resume Next How to use AND


Function in Excel
Me.txtregion.Value = Application.WorksheetFunction.VLookup(SLNo,
DECEMBER 10, 2018
Sheets(“data”).Range(“A2:N1087”), 2, 0)
Delete Duplicate in
Me.txtmarket.Value = Excel or Remove
Application.WorksheetFunction.VLookup(SLNo, Duplicate in Excel
Sheets(“data”).Range(“A2:N1087”), 3, 0) NOVEMBER 9, 2018

Me.txtbNum.Value = Application.WorksheetFunction.VLookup(SLNo, Excel Formulas PDF


Sheets(“data”).Range(“A2:N1087”), 4, 0) SEPTEMBER 6, 2018

Me.txtcnum.Value = Application.WorksheetFunction.VLookup(SLNo, How To Lock Cells in


Sheets(“data”).Range(“A2:N1087”), 5, 0) Excel | Unprotect
Excel
Me.txtcity.Value = Application.WorksheetFunction.VLookup(SLNo, AUGUST 13, 2018
Sheets(“data”).Range(“A2:N1087”), 6, 0)
4x Faster at Excel
Me.txtState.Value = Application.WorksheetFunction.VLookup(SLNo, AUGUST 6, 2018
Sheets(“data”).Range(“A2:N1087”), 7, 0)
Separate Content of
Me.txtpnum.Value = Application.WorksheetFunction.VLookup(SLNo,
Clyde  from London One Excel Cells into
Enrolled Excel VBA Course
Sheets(“data”).Range(“A2:N1087”), 8, 0) Separate Columns
⚡ few minutes ago
AUGUST 3, 2018
Me.txtSdate.Value = Application.WorksheetFunction.VLookup(SLNo,
Sheets(“data”) Range(“A2:N1087”) 9 0)
Sheets( data ).Range( A2:N1087 ), 9, 0)
How to Transpose
We'd like to show you notifications for the latest
Me.txtInum.Value = Application.WorksheetFunction.VLookup(SLNo, Excel Columns to
news and updates.
Sheets(“data”).Range(“A2:N1087”), 10, 0) Rows | Paste Special
Method
Me.txtIdate.Value = Application.WorksheetFunction.VLookup(SLNo,
NO THANKS ALLOW JULY 26, 2018
Sheets(“data”).Range(“A2:N1087”), 11, 0)
How to create
Me.txtSamount.Value = sparklines in Excel
Application.WorksheetFunction.VLookup(SLNo, JULY 19, 2018

Sheets(“data”).Range(“A2:N1087”), 12, 0)
AutoSum in Excel
Me.txtsp.Value = Application.WorksheetFunction.VLookup(SLNo, with Shortcut
Sheets(“data”).Range(“A2:N1087”), 13, 0) JULY 17, 2018

Me.txtSR.Value = Application.WorksheetFunction.VLookup(SLNo, OFFSET Function in

Sheets(“data”).Range(“A2:N1087”), 14, 0)  Excel


JULY 6, 2018

Strikethrough
Shortcut in Excel &
Word
JULY 4, 2018

INDIRECT Function
with SUM, MAX, MIN
& Independent Cell
Value
JUNE 29, 2018

If you look at the code very carefully you will notice that I have applied
Pivot Table Slicers In
vlookup formula to  pull up the value for the other boxes. You need to give a
Excel
proper name for all the text boxes you are going to use in the form.
JUNE 12, 2018

Recommended:
How to Wrap Text in
Excel Automatically
Update and Delete Using Excel VBA Userform, Remove Password From Excel
Clyde  from London
and Manually
Using ExcelEnrolled
VBA (Coding)
Excel VBAor you can learn much more related tips & tricks.
Course
⚡ few minutes ago JUNE 6, 2018
Learn More

Create Dynamic Graphs & Excel Presentation. Also, Learn How to create Data
Analytic Chart & Graph. Learn More How to Hide/Unhide
We'd like to show you notifications for the latest
Column in Excel
news and updates.
Now you choose any value from the SL No drop down box and you will see JUNE 5, 2018

the values are coming from the excel sheet as shown in Picture 2.
Highlight row based
NO THANKS ALLOW
Now if you want to update any info’s then what are the things need to do. on cell value
JUNE 4, 2018
Whatever value you choose from the drop down it is fetching the value of
corresponding columns, Right?

So we need to first select the entire row then we can set the cell value as per
our requirement.

If you choose 1 from my SL No drop down then it is showing the value from
row no 2. Isn’t it? As the first row is the header. Now we need to play with this
trick.

Create a Command Button and give the name like cmdupdate and change
the caption to Update.

 
Clyde  from London
Enrolled Excel VBA Course
A er setting theminutes
⚡ few above agoproperties double click on the “Update” button and

paste the below code between sub and end sub


We'd like to show you notifications for the latest
If Me.cmbslno.Value = "" Then
news and updates.

MsgBox "SL No Can Not be Blank!!!", vbExclamation, "SL No"


NO THANKS ALLOW

Exit Sub

End If

SLNo = Me.cmbslno.Value

Sheets("data").Select

Dim rowselect As Double

rowselect = Me.cmbslno.Value

rowselect = rowselect + 1

Rows(rowselect).Select

Cells(rowselect, 2) = Me.txtregion.Value

Cells(rowselect, 3) = Me.txtmarket.Value
Clyde  from London
Enrolled Excel VBA Course
⚡ few minutes ago
Cells(rowselect, 4) = Me.txtbNum.Value
Cells(rowselect, 5) = Me.txtcnum.Value
We'd like to show you notifications for the latest
news and updates.

Cells(rowselect, 6) = Me.txtcity.Value
NO THANKS ALLOW

Cells(rowselect, 7) = Me.txtState.Value

Cells(rowselect, 8) = Me.txtpnum.Value

Cells(rowselect, 9) = Me.txtSdate.Value

Cells(rowselect, 10) = Me.txtInum.Value

Cells(rowselect, 11) = Me.txtIdate.Value

Cells(rowselect, 12) = Me.txtSamount.Value

Cells(rowselect, 13) = Me.txtsp.Value

Cells(rowselect, 14) = Me.txtSR.Value

Your code will look like below:

Clyde  from London


Enrolled Excel VBA Course
⚡ few minutes ago
We'd like to show you notifications for the latest
news and updates.

NO THANKS ALLOW

(Picture 6)

A er pasting the above code then run the code and change the value of any
field and click on update button. You will see that changes made in value by
you in the Userform for that SL No header is reflected in the Sheet’s
respective Cell.

We can modify the code a little bit also. A er one record is modified if we
want to modify another record then….Do we need to start from the scratch
once again?

No… what we can do is we simply give a message box which will prompt that
records have been modified. Do you wish to continue?

Recommended:

Update and Delete Using Excel VBA Userform, Remove Password From Excel
Using Excel VBA (Coding) or you can learn much more related tips & tricks.
Learn More

Create Dynamic Graphs & Excel Presentation. Also, Learn How to create Data
Analytic Chart & Graph. Learn More

Clyde  from London


For that,Enrolled
we need to add
Excel VBA the below code
Course
⚡ few minutes ago

rowselect = rowselect - 1
We'd like to show you notifications for the latest
msg = "Sl No " & rowselect &news and updates.
"  Successfully Updated...Continue?"

NO THANKS ALLOW
Unload Me

ans = MsgBox(msg, vbYesNo, "Update")

If ans = vbYes Then

UserForm1.Show

Else

Sheets("Data").Select

Now if you run the code and choose any SL No then you will get all the values
for the other boxes. If you change any value of any box and click on “Update”
button, you will see the same value is now updated in the sheet and it will
give you a message that SL No has been updated and do you want to update
other SL No or not.

Clyde  from London


Enrolled Excel VBA Course
⚡ few minutes ago

(Picture 7) – VBA user form


If you click on Yes then the same We'd
form will
likebe
to reloaded
show youand by clicking for
notifications on No
the latest
you will be redirected to the sheetnews
whereand
youupdates.
have updated the data.

Learn how to use Flash fill in Excel and related tips & tricks in Excel VBA
NO THANKS ALLOW
Course: Click here for more details

We will apply the theory in case of delete and then apply the below code

Sheets("Data").Select

Dim msg As String

Dim ans As String

If Me.cmbslno.Value = "" Then

MsgBox "Sl No can not be Blank!!", vbExclamation, "SL No"


Clyde  from London
Enrolled Excel VBA Course
⚡ few minutes ago
Exit Sub
End If We'd like to show you notifications for the latest
news and updates.

Dim rowselect As Double


NO THANKS ALLOW

rowselect = Me.cmbslno.Value

rowselect = rowselect + 1

Rows(rowselect).EntireRow.Delete

rowselect = rowselect - 1

msg = "Sl No " & rowselect & "  Successfilly Deleted...Continue?"

Unload Me

ans = MsgBox(msg, vbYesNo, "Delete")

If ans = vbYes Then

UserForm1.Show

Else

Clyde  from London


Enrolled Excel VBA Course
Sheets("Data").Select
⚡ few minutes ago

d f
End If
We'd like to show you notifications for the latest
news and updates.

NO THANKS ALLOW
Download Working Files

Now if you want you may hide the sheet from the user. So that user will
update or delete the data using the userform only. But here is one problem.
Every time you need to choose the value from the SL no drop-down button.

Why not such type of userform where I need to choose only 1 time and then I
can add, update, delete, previous, next all the button in a single user. We will
create the same in the next blog

Recommended Courses:

Excel
VBA
Course
[Beginner
to
Advanced]

Automate
everything
that you do in Excel with Excel VBA and Macros. Learn step by step Coding
with our Excel VBA Course which gives you a Complete Beginners to
Advanced level guide. From recording and running macros to using Loops
Clyde  from
and creating London Functions. Take the best VBA Course and get
User-defined
Enrolled Excel VBA Course
started⚡now.
few minutes ago
Excel Dashboard Course 
We'd like [Beginner to Advanced]
to show you notifications for the latest
news and updates.
Learn to
create the
NO THANKS ALLOW
best and
interactive
Dashboard
s from
scratch.
Know
everything
for creating dynamic Dashboards from creating Charts and trendlines
from Pivot Table to using Advanced INDEX and MATCH with Multiple
Reference to Extracting Data from Multiple Sheets using OFFSET and
INDIRECT Function. Clear your Dashboard fundamentals and take the
best course ever on Excel Dashboards

0 SHARES    

# PREV N E XT $

About Us Links Recent Blog Certi cate of


Completion
Clyde  from London
We  Free Online Course
Enrolled Excel VBA Course How to use Ceiling
⚡ few minutes ago Video
o er instructional Function in Excel
videos, practice files,  Download Ebooks JANUARY 30, 2019
and a personalized  Privacy Policy How to use Char
We'd like to show you notifications for the latest
learning dashboard Function in Excel
 Refund
news Policy
and updates.
that empower JANUARY 28, 2019

an individual to  Terms of Use


Text To Column in
master use cases of NO THANKS ALLOW
 Corporate Training Excel | Split Cells
the so ware at their
JANUARY 4, 2019
own pace anytime  Contact

anywhere. We work
with 20+ industry
experts who double
up as award-winning
instructors for our
courses.

Clyde  from London


Enrolled Excel VBA Course
⚡ few minutes ago