UrbanPro
true

Learn Microsoft Excel Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

VBA Function -

Using FORMAT Function in VBA we can modify the format of Numbers, Dates, Times & String.

Syntax: FORMAT(expression, format, [firstdayofweek], [firstweekofyear])

1. Formatting "Numbers" using FORMAT function in VBA

SUB Format_Numbers()

MsgBox format(8686836999, "####-###-###")

'Output: '8686-836-999'

MsgBox format(143.5, "#,##.00")

'Output: '143.50'

MsgBox format(1729.4, "Currency")

'Output: '$1,729.40'

MsgBox format(0.9156, "Percent")

'Output: '91.56%'

MsgBox format(1729.4, "Standard")

'Output: '1,729.40'

End Sub

2. Formatting "Dates" using FORMAT function in VBA

Sub FORMAT_Dates()

MsgBox format("3/21/2017", "Short Date")

'Output: '3/21/2017'

MsgBox format("3/21/2017", "Medium Date")

'Output: '21-Mar-17'

MsgBox format("3/21/2017", "Long Date")

'Output: 'Tuesday, March 21, 2017'

MsgBox format("3/21/2017", "mmm dd")

'Output: 'Mar 21'

End Sub

3. Formatting "Time" using FORMAT function in VBA

Sub FORMAT_Time()

MsgBox format("6:30:45", "Short Time")

'Output: '06:30'

MsgBox format("6:30:45", "LONG Time")

'Output: '6:30:45 AM'

MsgBox format("6:30:45", "MEDIUM Time")

'Output: '06:30 AM'

MsgBox format("14:30:45", "HH:MM")

'Output: '14:30'

End Sub

4. Formatting "Text" using FORMAT function in VBA

Sub FORMAT_Text()

MsgBox format("EXCEL IS MAGIC", "<")

'Output: 'excel is magic' (convert text to lower case)

MsgBox format("excel is magic", ">")

'Output: 'EXCEL IS MAGIC' (convert text to upper case)

End Sub

 

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Vlookup in excel
Vlookup is a very useful formula in excel. Vlookup can be used in two ways Exact and approximate. We can find and fill in data with the help of Vlookup. The syntax of Vlookup is: Vlookup (Lookupvalue,...

How to work fast while working on MS Excel?
Many people struggle to find out the way on how they can work faster while working on MS Excel/Access or VBA. let me share the tip for that. If you are new or working since long time on Excel/Access...

Excel
The 1900 Date System In the 1900 date system, the first day that is supported is January 1, 1900. When you enter a date, the date is converted into a serial number that represents the number of elapsed...

When should you use TRUE in vlookup?
You can use TRUE as the last argument in vlookup function when you are looking up using which is a range with a lower limit and an upper limit. For example if you want to charge a customer according to...

Akhilesh Dadhich

0 0
0

Hidden Gems of MS Excel - Compare Year-on-Year Performance Using Pivot Table
Did You know You can Compare Year-on-Year& Performance Using Pivot Table?Yes. Just drag-&-drop and Compare Year-on-Year& Performance Quickly.& Year-on-Year simply means Periodic. As per...
X

Looking for Microsoft Excel Training Classes?

The best tutors for Microsoft Excel Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Microsoft Excel Training with the Best Tutors

The best Tutors for Microsoft Excel Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more