Disclaimer
Ready to Use Powerful Excel VBA Code (Part 2) Customize Function is anindependent publication and is not affiliated with, nor has it been authorized,sponsored, or otherwise approved by Microsoft Corporation.
Trademarks
Microsoft, Visual Basic, Excel and Windows are either registered trademarks ortrademarks of Microsoft Corporation in the United States and/or other countries.
Liability
The purpose of this book is to provide basic guideline for people interested in ExcelVBA programming. Collection of ready code has been used on reality platform bytechnical and non technical users on their routine. Although every effort and care hasbeen taken to make the information as accurate as possible, the author shall not beliable for any error, harm or damage arising from using the instructions given in thisbook.
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, without permission in writing from the author.
Acknowledgement
I would like to express my sincere gratitude to many people and Excel LearningWebsites who have made their contributions in one way or another to the successfulpublication of this book.
My special thanks go to my Parents and Gurudev (Acharya Sh Ramesh) and friendMr. Rakesh Jain (Charvi Associates) having expert knowledge of web programming& My Accounts, HR, IT & ERP Departments Colleaguecontributed their ideas andeven wrote some of the sample programs for this book. I would also like toappreciate the support provided by my beloved wife Manisha Jain, son MasterSamkit and youngest daughter Samiksha Jain and Friends.
I would also like to thank the millions of visitors to my Smart Excel & Learningwebsite at http://www.anilnahar.com l for their support and encouragement.
About the Author
Anil Nahar holds a Master degree inComputer Application (MCA), a Bachelordegree in Commerce (B.Com.) and Three year completed C.A. trainingby ICAI (Institute of Chartered Accountant of India). He is working on real platform with aesteem organization on Functional as well as Technical Support in Excel. He isprovided many smart excel training programmes in corporate and appreciated bymanagement.He has been involved in programming for more than 10 years. Hecreated the popular online Smart Learning Tricks Tutorial at www.anilnahar.com in2017 and since then the web site has attracted millions of visitors and it is one of thetop searched VBA Excel websites in many search engines including Google.
Related Book Published
Ready to Use 101 Powerful Excel VBA CodeJust Copy - Paste - Run(For Functional Users)
Contents
User-Defined Functions
Excel having large collection of functions in-built . Mostly those functions aresufficient to complete the work. Sometimes, Excel doesnt have a pre-built functionthat suits a specific need, Well not to worry about it , you can create your ownfunction called User Defined Function or custom Excel function with help ofVisual Basic for Applications (VBA). You can access a User Defined Function any time just like any other Excel function.
But the main problem is you should have good knowledge of Excel VBAProgramming and need so much time to writing code as desire.
This book helps you to use ready code by just copy paste and enjoy the work.Benefits of this books :
Available readymade function which is very unique and rare.Create new formula in easy way instead of using long formulaWithout any technical knowledge use the new functionImpress your boss with fast workingEarn 10000$ per month by making new project with help of my other book Ready to Use 101 Powerful Excel VBA Code
Lets know how to use User define function :
The following steps can be used to create UDFs:
1. Open up a new workbook.
2. Open the Visual Basic Editor by pressing Alt+F11.3. Insert a new module.
4. Copy and Paste the code that makes up the UDF
5. Press Alt+Q to exit the Visual Basic Editor (VBA)
6. Use the function - They will appear in the Paste Function dialog box (Shift+F3)under the "User Defined" category
If you want to use a UDF in more than one workbook, you can save your functions inyour own custom add-in. Simply save the Excel file that contains your VBA functions as an add-in file (.xla). Then load the add-in (click Tools then Add-Ins...).
Awareness: Be careful about using custom functions in spreadsheets that you needto share with others. If they don't have your add-in, the functions will not work whenthey use the Worksheet.
Text to Column of Cell value by Separator
By Excel Formula123456==> Number of Words
ValueSplit Text
Anil Kumar Jain Kumar Jain Jain
Anil Kumar Jain AnilAniAnA
Anil Kumar Jain
By UDF
ValueSplit Text
Anil Kumar Jain AnilKumarJain
Function : = TTC($A$11, " ", B2)
Ready Code :
Function TTC(Ref_Cell, separator, num_words) As String'Smart Function for Split text in column by given separator'Smart Excel (www.anilnahar.com)'Forumula like =TTC($A$9, " ", 1) ==> Separator space( ) , first numberDim T() As StringT = Split(Ref_Cell, separator)TTC = T(num_words - 1)
Extract Bold Value From a Cell
ParticularsExtract Bold ValueThis is My Function to extract Bold Value FunctionThis is My Function to extract Bold Value Functionextract BoldThis is My Function to extract Bold Value My Bold Value
Function : = BoldText(A2)
Ready Code :Function Boldtext(ByVal rngText As Range) As String'Smart Function for extract text which has Bold'Smart Excel (www.anilnahar.com)Boldtext = ""Dim theCell As RangeSet theCell = rngText.Cells(1, 1)For I = 1 To Len(theCell.value)If theCell.Characters(I, 1).Font.FontStyle = "Bold" ThentheChar = theCell.Characters(I, 1).textResults = Results & theCharEnd IfNext IBoldtext = Results
Reverse the Cell Text
Particulars
Anil Kumar JainSmart Excel
anilnahar.com
Reverse Text Function : = reverse(A2)
niaJ ramuK linA
lecxE tramS
moc.rahanlina
Ready Code :Function Reverse(text As String) As String'Smart Function for find Reverse text of cell'Smart Excel (www.anilnahar.com)Reverse = StrReverse(Trim(text))End Function
Find Factorial Number
VALUEFactorial Number
36 Function : = reverse(A2)
424
5120
6720
75040
840320
9362880
103628800
Ready Code :Public Function Factorial(num As Integer) As Long'Smart Function for find Factorial value
'Smart Excel (www.anilnahar.com)
Dim F_output As LongDim I As Integer
If num = 0 Then
F_output = 1
ElseIf num = 1 Then
F_output = 1
Else
F_output = 1
For I = 1 To num
F_output = F_output * INext
End If
Factorial = F_output
Merging Cell value by Separator i.e. Concatenate
FirstMiddleLastMerge Column TextAnilKumarJainAnil,Kumar,JainRajKumarSaxenaRaj,Kumar,SaxenaMinakshideviSuranaMinakshi,devi,Surana
Function : = concat(A2:C2)
Ready Code :Public Function Concat(rIn As Range) As String'Smart Function for Concatnate one more column in single column'Smart Excel (www.anilnahar.com)'Change comma(,) separator where you need other sign'Formula like =concat(A2:C2)For Each r In rInConcat = Concat & "," & r.textNext rConcat = Mid(Concat, 2)