Personal Function Test if a cell is bold
Personal Function Test if a cell is bold • Macro’s aim : You have to multiply the content of a cell by two if it is in bold type Make it out!! -Write it down in Cell C 2 : Test. Gras(B 2) -Copy the formula for the other cells -For multiplying by 2 the content in bold type, let include this formula : SI(Test. Gras(B 2); B 2*2; B 2)
CODE Function Test. Gras(Cellule) If Cellule. Font. Bold Then Test Gras = True Else Test. Gras = False End If End Function Fonction Test. Gra (): It receive as parmeter the reference for a cell The adress of a Cell is coming to Argument when this function is registered on a formula. End Fonction: It returns the content of the variable having his name of Test. Gras.
Elements VBA • It is about a function not a Procedure • A function doesn’t appear on the liste of Macros • A fonction won’t be executed like a macro, for it is included in a formula • Let go to « Formulas » and « Include a function » then « select the category - Personal » • So then, there is your function VBA
Notices • The code of a function is located in a module and always is starting with the instruction Function fellowed by a name of the fuction • Arguments between brackets, by which the function is in action • The function treats the arguments, using the same instructions to a macro • If you want your functions to be usable in any workbook , regroup them in a filet you are registering on format Macro complémentiare
Créer une macro complémentaire 1. 2. 3. 4. 5. 6. 7. 8. Créez les macros, les routines, les feuilles VBA dans un classeur normal Go to OFFICE and register under OTHER FORMATS Select Macro Complémentaire on the list of type of file. A document be automatically seclected. Let it be as it be. Enter a name of the file, for instance, PERSO. It’s taking the extension. xlam. Now it needs for Macro to be activated. Go to OFFICE – Options EXcel-Complétents-Gérer and then, select Comléments Excel and click on button ATTEINDRE Select the ficher PERSO you have just created. Click on OK
- Slides: 5