• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
EDUCBA

EDUCBA

MENUMENU
  • Resources
        • Excel Charts

          • Histogram Chart Excel
          • Basic Excel Formulas
          • Text to Columns in Excel
        • Excel Charts
        • Excel Tips

          • Excel Gantt Chart
          • IFERROR with VLOOKUP
          • Data Table in Excel
        • Excel Tips
        • Excel Tools in Excel

          • Stacked Column Chart
          • Cheat Sheet of Excel Formulas
          • Excel Data Validation
        • Histogram chart in excel
        • Others

          • Resources (A-Z)
          • Excel Functions
          • Financial Functions in Excel
          • Logical Functions in Excel
          • Lookup Reference Functions in Excel
          • Maths Function in Excel
          • TEXT and String Functions in Excel
          • View All
  • Free Courses
  • All Courses
        • Certification Courses

          Excel Course 1
        • All in One Bundle

          All-in-One-Excel-VBA-Bundle
        • Excel course

          Excel-Training
        • Others

          • Excel advanced course
          • VBA Course
          • Excel Data Analysis Course
          • Excel for Marketing Course
          • Excel for Finance Course
          • View All
  • 120+ Courses All in One Bundle
  • Login

VBA Me

Home » Excel » Blog » VBA » VBA Me

VBA Me

Excel VBA Me Function

Just by seeing the name VBA Me, people must be wondering what kind of thing is it in VBA called VBA Me? This came to my mind as well when I heard this first time. VBA has an object called ME which is used in place of parent objects. This seems some typical function with complex syntax. But trust me, the syntax of VBA Me might have seen and used as well. Although, VBA Me is used in advanced limit and is not seen in regular commands.

I know, by reading so far, people still may have the question, What is VBA Me? Let’s understand this on a very ground level language. Consider yourself in this case. We all have been given different kind of nicknames since our childhood which can be 2 or more. But all have one official and real name by which we are called by the rest of the world. By which, we introduce us to the rest of the people. So, that real name will be ME in VBA Me object which can be used by replacing similar other identities. This example can be understood in the opposite manner as well.

Start Your Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

Frankly, VBA Me doesn’t have any defined syntax. This is used as a replacement for parent objects.

How to Use Excel VBA Me Function?

Below are the different examples to use Me Function in Excel VBA.

You can download this VBA Me Excel Template here – VBA Me Excel Template

VBA Me – Example #1

VBA ME can be implemented in Module and Sheet both. But we again need to know when should we use what. We can use VBA Me anywhere. It can be used in Class or Module. And Class has 2 modules i.e. Module with User Interface and Module without User Interface. Here, we will see the Module with User Interface. As said, we will execute this into a Module.

Below are the different steps to use VBA Me function.

Popular Course in this category
VBA Training (3 Courses, 12+ Projects) 3 Online Courses | 13 Hands-on Projects | 45+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.7 (2,695 ratings)
Course Price

View Course

Related Courses
Excel Advanced Training (14 Courses, 21+ Projects)Excel Data Analysis Training (12 Courses, 6+ Projects)

Step 1: Insert a new module in Visual Basic Editor (VBE). Click on Insert tab > select Module.

VBA Me Example 1-1

Step 2: Write subprocedure for VBA ME as shown below.

Code:

Sub VBA_Me()

End Sub

VBA Me Example 1-2

Step 3: Select Worksheet first. Here, we will be selecting the worksheet which is named as Sheet1.

Code:

Sub VBA_Me()

Worksheets("Sheet1")

End Sub

VBA Me Example 1-3

Step 4: Now select the range cell where we will be seeing the output value. Let that cell be B2 and the value be “VBA Me” as shown below.

Code:

Sub VBA_Me()

Worksheets("Sheet1").Range("B2").Value = "VBA Me"

End Sub

VBA Me Example 1-4

Step 5: Now run the code by pressing the F5 key or by clicking on Play Button. We will see the value is printed in cell B2.

VBA Me Example 1-5

Here, the ME Object will be the name of Sheet which we have selected with the help of Worksheets function. So now we will replace that with ME. But again this won’t work under Module.

Step 6: Go to the sheet which we have selected, i.e. Sheet1.

VBA Me Example 1-6

Step 7: And place the same code as we have seen in Module and replace worksheet function with ME as discussed. Here, for change, we have selected the Range as A2.

Code:

Sub VBA_Me()

Me.Range("A2").Value = "VBA Me"

End Sub

VBA Me Example 1-7

Step 8: Again run the code by pressing the F5 key or by clicking on Play Button.

VBA Me Example 1-8

We will see, VBA ME has returned the text value in cell A2 as well. This is how we can interchange parent object with VBA ME.

VBA Me – Example #2

Now the same VBA ME we will see in User Form. For this, follow the below steps:

Step 1: Open a User Form from Insert menu tab as shown below.

Select UserForm

This will look like this.

User Form with ToolBox

Step 2: In this toolbox select TextBox.

Select TextBox

Step 3: Drag this TextBox on the user form.

Drag this TextBox

Here we are selecting Text box so that we would see the output what we will feed in.

Step 4: Double click on the created text box which we will direct us to edit code mode.

Code:

Option Explicit

Private Sub TextBox1_Change()

End Sub

VBA Me Example 2-5

Step 5: Write the code to select the User Form and Text box which we have created.

Code:

Option Explicit

Private Sub TextBox1_Change()

UserForm1.TextBox1.Value

End Sub

Select the User Form and Text box

Step 6: Now select the text which you want to see in the Text box of User Form. Let that text be “Testing Ok!”.

Code:

Option Explicit

Private Sub TextBox1_Change()

UserForm1.TextBox1.Value = "Testing Ok!"

End Sub

Select the text

Step 7: Now run the code by pressing the F5 key or by clicking on Play Button. We will get a User Form with a Text box in it as shown below. Now if we try to enter anything in that text box, we will see the output message we have set just above.

VBA Me Example 2-8

Here, our ME object will be the name of User Form which is the parent object.

Step 8: So we can replace that with ME to execute VBA ME.

Code:

Option Explicit

Private Sub TextBox1_Change()

Me.TextBox1.Value = "Testing Ok!"

End Sub

VBA Me Example 2-9

Step 9: Again run the code.

VBA Me Example 2-10

Step 10: And try to type anything in the Text box. We will see the same output message in the text box which we have received before.

VBA Me Example 2-11

This is how we can implement VBA ME anywhere by replacing Parent object with ME.

VBA Me – Example #3

There is another simple example to see how VBA Me works. We have created a sheet and named it as Test.

Step 1: Open that sheet in VBA and write the code where we will the name the newly created sheet in the message box.

Code:

Sub VBA_Me2()

MsgBox Sheet2.Name

End Sub

Use MsgBox

Step 2: Now run the code. We will get the name of sheet as Test.

VBA Me Example 3-2

Step 3: Here, Sheet2 has become our object which can be replaced. So, we can replace with ME as shown below.

Code:

Sub VBA_Me2()

MsgBox Me.Name

End Sub

VBA Me Example 3-3

Step 4: And the run the code again. We will see, the name of Sheet Test will be seen in message box.

VBA Me Example 3-4

Pros & Cons of Excel VBA Me

  • It seems complex but it is very easy to implement.
  • We can replace any object with VBA Me.
  • This also helps in reducing the size of code by removing unwanted, mistakable object functions.
  • ME also provides the reference to select a specific instance of Class of the same code.
  • It cannot be implemented in Module.

Things to Remember

  • We need to replace the same object function of parent object which is there in the same Sheet or User Form of the code.
  • It automatically becomes available to every subcategory in the same Class or Form.
  • VBA Me can be used with any type of code where we see the replacement of the parent object.
  • VBA Me can directly be used where we can just use Debug Print or message box where instead of selecting the debugging function or variable, we can replace that with VBA ME.

Recommended Articles

This is a guide to VBA Me Function. Here we discuss how to use Excel VBA with Me Function along with practical examples and downloadable excel template. You can also go through our other suggested articles –

  1. VBA DoEvents (Examples with Excel Template)
  2. How to Use AutoFill in VBA?
  3. VBA Format Number (Examples)
  4. What is VBA GetObject Function?

All in One Excel VBA Bundle (120+ Courses, 30+ Projects)

120+ Online Courses

30+ Projects

500+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Reader Interactions
Leave a Reply Cancel reply

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

Primary Sidebar
Excel Functions Tutorials
  • VBA
    • VBA Max
    • VBA Environ
    • VBA Not
    • VBA LOOKUP
    • Programming in Excel
    • VBA Name Worksheet
    • VBA ScreenUpdating
    • VBA Do Loop
    • VBA Declare Array
    • VBA Macros
    • VBA Delete Sheet
    • VBA Editor
    • VBA Error Handling
    • VBA Goal Seek
    • VBA DateDiff
    • VBA On Error Resume Next
    • VBA Examples
    • VBA Counter
    • VBA Val
    • VBA Me
    • VBA Double
    • VBA Variable Types
    • VBA FreeFile
    • VBA Switch Case
    • VBA Unprotect Sheet
    • VBA Format Number
    • VBA ReDim
    • VBA IF Statements
    • VBA DoEvents
    • VBA Public Variable
    • VBA Columns
    • VBA Cdate
    • VBA Selection Range
    • VBA Hide Columns
    • VBA COUNTA
    • VBA Insert Row
    • VBA Protect Sheet
    • VBA AutoFill
    • VBA IF Not
    • VBA GetObject
    • VBA Debug Print
    • VBA Collection
    • VBA Text
    • VBA Randomize
    • VBA Variant
    • VBA Selection
    • VBA Right
    • VBA Date Format
    • VBA Rename Sheet
    • VBA Paste Values
    • VBA InputBox
    • VBA Conditional Formatting
    • VBA Pause
    • VBA Pivot Table
    • VBA Message Box
    • VBA OFFSET
    • VBA ByRef
    • FileCopy in VBA
    • VBA StrConv
    • VBA SUB
    • VBA Boolean
    • VBA Global Variables
    • VBA Worksheets
    • VBA IIF
    • VBA Close UserForm
    • VBA Variable Declaration
    • VBA Join
    • VBA Dictionary
    • VBA Operators
    • VBA Charts
    • VBA For Each Loop
    • VBA FileDialog
    • VBA Format
    • VBA MID
    • VBA GetOpenFileName
    • VBA DatePart
    • VBA Code
    • VBA Option Explicit
    • VBA FileSystemObject (FSO)
    • VBA ASC
    • VBA UserForm
    • VBA Cells
    • VBA InStrRev
    • VBA Class Module
    • VBA Constants
    • VBA Length of String
    • VBA DateSerial
    • VBA StrComp
    • VBA Array Length
    • VBA Check File Exists
    • VBA Ubound
    • VBA CDBL
    • VBA Activate Sheet
    • VBA DateValue
    • VBA Borders
    • VBA Comment
    • VBA Intersect
    • VBA Workbook
    • VBA Concatenate
    • VBA Name
    • VBA Find and Replace
    • VBA Tutorial
    • VBA CSTR
    • VBA Save As
    • VBA Hyperlink
    • VBA Print
    • VBA Switch
    • VBA END
    • VBA Like
    • VBA Set
    • VBA excel programming
    • VBA Call Sub
    • VBA Object
    • VBA RoundUp
    • VBA ArrayList
    • VBA Named Range
    • VBA PowerPoint
    • VBA Block Comment
    • VBA OverFlow Error
    • VBA Insert Column
    • VBA Lcase
    • VBA List Box
    • VBA Delete File
    • VBA Clear Contents
    • VBA TextBox
    • VBA Font Color
    • VBA Range Cells
    • VBA INT
    • VBA UCASE
    • VBA Value
    • VBA Remove Duplicates
    • VBA Break for Loop
    • VBA Sleep
    • VBA Do Until Loop
    • VBA Union
    • VBA Long
    • VBA Copy Paste
    • VBA Data Types
    • VBA Delete Column
    • VBA Enum
    • VBA IsEmpty
    • VBA 1004 Error
    • VBA RegEx
    • VBA IsNumeric
    • VBA Paste
    • VBA Transpose
    • VBA Left
    • VBA Delete Row
    • VBA Integer
    • VBA Active Cell
    • VBA InStr
    • VBA Round
    • VBA Subscript out of Range
    • VBA Dim
    • VBA Replace
    • VBA Sort
    • VBA String
    • VBA Split
    • VBA Wait
    • VBA MOD
    • VBA Time
    • VBA TIMER
    • VBA While Loop
    • VBA Date
    • Excel VBA MsgBox
    • VBA IFError
    • VBA Color Index
    • VBA Match
    • VBA Case
    • VBA Arrays
    • VBA GoTo
    • VBA On Error
    • VBA Range
    • VBA Do While Loop
    • VBA Number Format
    • VBA Loops
    • VBA TRIM
    • VBA Find
    • VBA Select Case
    • VBA Else If
  • Excel Functions (10+)
  • Excel Tools (97+)
  • Financial Functions in Excel (17+)
  • Logical Functions in Excel (12+)
  • Lookup Reference Functions in Excel (30+)
  • Maths Function in Excel (39+)
  • TEXT and String Functions in Excel (25+)
  • Date and Time Function in Excel (20+)
  • Statistical Functions in Excel (55+)
  • Information Functions in Excel (4+)
  • Excel Charts (44+)
  • Excel Tips (195+)
  • Workplace Productivity (4+)
  • Microsoft Office Tools (14+)
  • Excel Formula and Functions (20+)
  • MS Excel Shortcuts (4+)
Excel Functions Courses
  • VBA Training
  • Excel Advanced Training
  • Excel Data Analysis Training
Footer
About Us
  • Who is EDUCBA?
  • Sign Up
  •  
Free Courses
  • Free Online Excel Course
  • Free Vba Course
Certification Courses
  • All Courses
  • Excel VBA Course - All in One Bundle
  • VBA Course
  • Excel Data Analysis Course
  • Excel for Marketing Course
  • Excel for Finance Course
  • Excel for HR Training
Resources
  • Resources (A To Z)
  • Excel Charts
  • Excel Tips
  • Excel Tools in Excel
  • Excel Functions
  • Financial Functions in Excel
  • Logical Functions in Excel
  • Lookup Reference Functions in Excel
  • Maths Function in Excel
  • TEXT and String Functions in Excel
  • Date and Time Function in Excel
  • Statistical Functions in Excel
  • Information Functions in Excel
Apps
  • iPhone & iPad
  • Android
Support
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions

© 2019 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

Download VBA Me Excel Template

By continuing above step, you agree to our Terms of Use and Privacy Policy.
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Let’s Get Started
Please provide your Email ID
Email ID is incorrect

Limited Period Offer - All in One Excel VBA Bundle (120+ Courses, 500+ hours of Videos) View More

Limited Period Offer - Limited Period Offer - All in One Excel VBA Bundle (120+ Courses, 500+ hours of Videos) View More