Showing posts with label Excel Tricks. Show all posts
Showing posts with label Excel Tricks. Show all posts

Tuesday, September 29, 2020

Create or Insert a New Module in VBE

In this tutorial, we are going to explain you how to Insert or Create a New Module in the Visual Basic Editor (VBE).

To Insert or Create a New Module, please follow the beneath steps:


  1. Open the workbook in which you want to insert the Module.
  2. Press Alt+F11 key from your keyboard to open the Visual Basic Editor (VBE) window.
  3. Click on the Insert tab in the VBE, and click on the Module option


  4. At the Right Side of the Project Explorer Window, A code window will be opened. You can Enter your new code or Copy-Paste any of your existing code there.


Friday, August 14, 2020

Email a Single Excel Worksheet from a Workbook

Sometimes, you may need to send a part of the worksheet or a single excel worksheet from the workbook to your colleague or boss. If you want to e-mail a single worksheet from a workbook. Then, instead of saving a copy of that workbook and deleting the unwanted content. Here is a quicker way to do it:

Note: This will only work when Outlook is set up on your computer.

  1. Select the worksheet/tab you want to e-mail or If you want to send more than one worksheet, then hold down the Ctrl key & click on the each worksheet which you want to send in e-mail. Then,
  2. Right-click on the selected worksheet/tab and Click on the Move or Copy option (as shown in below screenshot). Then,

    Move Or Copy Option Image
     
     
  3. In the To book: field select (new book) and check mark the Create a copy option and Click on OK button (as shown in below screenshot)

    Move Or Copy Option Dialog Box Image

  4. The worksheet/s will now be opened in a separate workbook with a default name, i.e. Book1.
  5. In this workbook, Go to File > Share > Email > click on Send as Attachment option (as shown in below screenshot).
  6. Six

    Share - Email As Attachment Image

Thursday, August 13, 2020

All Excel Keyboard Shortcuts at One Place

We have gathered all the Keyboard Shortcuts of Microsoft Excel at one place. To easy access of yours, we have categorized all the shortcuts. Now, you can find the required category and can easily access the list of shortcuts by clicking on the links listed below and increase your productivity.

Note: Here, You can find the shortcut keys for Mac & Windows both the platforms.

Excel Ribbon Tab Shortcuts for Windows

Shortcuts to Make Selections in Excel

Formatting Cell Shortcuts in Excel

Inside the Ribbon Shortcuts in Excel

Frequently Used Keyboard Shortcuts For Mac & Windows in Excel

Excel Cell Navigation Shortcuts For Mac & Windows

Formula Shortcuts For Mac & Windows

Increase Productivity using these Top Excel Keyboard Shortcuts



Saturday, May 9, 2020

Create a Custom Function in Excel - UDF

You can create your very own functions that do whatever you want it to; are called User Defined Functions or UDF and they are amazing.

To make these functions; we just need a little bit of VBA Coding since they are basically macros.

Steps to Create a UDF in Excel

  1. Hit Alt + F11 to go to the VBA Editor window



  2. Go to Insert > Module



  3. You should now see a window that looks like this:



  4. In that window type Function and the name of your function and then an open and closing parenthesis and then hit Enter. I named my function CountCharacters

  5. You can give your function basically any name that is not already used for functions.

    Once you do this, the window will automatically add End Function to the window and it should look something like this:





  6. Put some code within the function to make it do something.

  7. Here, I will simply set a variable equal to some text that I would like to output.
    outputText = "This is output."

  8. Now, we need to put the output of our function into a variable that has the SAME name as our function.

  9. To do this, I add this line of code to the bottom of the function's code:
    CountCharacters = outputText


  10. Hit Alt + F11 to go back to Excel and input the new function into a cell.



  11. Notice that when I start typing the name of the function it appears in the function list drop-down for Excel.

    When you finish entering the function hit Enter like you would with a regular function.

  12. That's it! Here is the final result.



  13. In this example, I created the simplest form of a UDF or User Defined Function.

Every UDF that you create will follow the basic structure outlined in this example, which is:

  1. Functions must start with Function and then the name you want to give that function and an open and closing parenthesis. Arguments can go into the parenthesis, as discussed below in another example.
  2. Functions must end with the text End Function, which the Excel VBA window will usually input for you.
  3. To generate the output for the function and send it back to Excel, you must assign the output of the function to a variable that has the exact same name as your function.


Adding Arguments to the Function


Let's now add an argument to the function in order to make it more useful.

Arguments are the parts of a function where you can input data, or select a cell that has data, that you want your function to use. Arguments are the way you get data into your function.

It's actually very simple; we just input text in-between the parenthesis after the name of the function, and that text will be the argument.

Let's start with the example we made above:



Now, add text in the parenthesis:



I put input_value as the argument. Note that you can't use spaces for the names, instead, separate words using underscores.

Now that we have input_value as an argument, we can use it within the function. This is how we get data from the user into the function.

To make this function more dynamic, since it currently only outputs the hardcoded text "This is output.", I will set the variableoutputText equal to the new argument input_value.



Go back to Excel (hit Alt + F11) and let's try this function on another cell.



Here is the result:



This simple function now outputs whatever text is given to it, in this case, the text from cell A1.


Multiple Arguments


You can have multiple arguments, just separate each one with a comma like this:
Function MyFunctionName(Argument_1, Argument_2, Etc.)

Using VBA within the Function


We are creating this function using VBA (Visual Basic for Applications), which is the same thing we use for regular macros. As such, we can do many interesting and powerful things. Now, functions can't do everything that a regular macro can do, because the goal of a function is to return a result back to the cell, but you can still do a lot.

Let's finish the function we started to create and make it count all of the characters that are in a cell.

To do this, we add the len VBA function, which is used to count the length of the value that you put inside of it.

I want to count the input to this function, which is provided through the input_value variable and so I need to put that inside the len function.

This:
outputText = input_value

Will become this:
outputText = len(input_value)




Since the rest of the function is already setup to output the value stored in the outputText variable, I don't need to change anything else.

Here is the final Function code:



Go back to Excel and try it now.



Output is:


We now have a function that counts how many characters are in a cell and gives us the result.


The Final Result: Custom Excel Function


This was a very simple example using VBA to create a function but you can include many lines of code depending on the complexity of what you are trying to do. In this example, I tried to keep things simple to help give you an idea of how everything works so you can build upon it.
Here is the final version of the code that was created:

Function CountCharacters(input_value)  
   
   outputText = Len(input_value)  
   
   CountCharacters = outputText  
   
 End Function



Notes


Custom Excel functions, or UDFs, are simply awesome. They are one of my favorite aspects of Excel because it allows you to easily create a function that does almost whatever you could want it to do. When you have repetitive tasks that take many steps or require a complex formula that is hard to remember, you can create a custom function to do the work for you.

The example that I created above is not a useful custom function on its own since there is already a LEN() function in Excel, but it should help you to understand how custom functions are made and used.

UDFs are only available in the workbook in which you have them or when that workbook is open and you are referencing them using the correct cross-workbook method, with is rather annoying. In another tutorial I will show you how to make them available everywhere.




Monday, May 1, 2017

Increase Productivity Using Top Excel Keyboard Shortcuts

Read this post to know the Top Excel Keyboard Shortcuts to Increase your Productivity

These shortcuts are easy to learn and are ones that I use almost every day.

Move Between Worksheets


Ctrl + Page Down
Move to the next worksheet to the right.
Ctrl + Page Up
Move to the next worksheet to the left





Move Up, Down, Left, or Right After Entering Data

You can use all of these to enter data or simply move around the spreadsheet.
 

Enter                 
Move down one cell.
Tab                    
Move to the right one cell.
Shift + Enter 
Move up one cell.
Shift + Tab
Move to the left one cell.

Jump to the First or Last Cell in a Worksheet


Ctrl + Home
Move to the upper left most cell, cell A1.
Ctrl + End
Move to the lower right most cell that contains data.

Jump to the Bottom or Top or Side of a Data Set


Ctrl + Up Arrow
Move to the top of the current data set.  If there are empty rows above the current cell but below the top of the data set, you will have to use this a few times to get to the top.



Ctrl + Down Arrow
Move to the bottom of the current data set. If there are empty rows below the current cell but above the bottom of the data set, you will have to use this a few times to get to the bottom.


Quickly Select a Range of Data

Ctrl + Shift + Down or Ctrl + Shift + Right or Ctrl + Shift + Left or Ctrl + Shift + Up
Use these keyboard shortcuts until the desired section of data has been selected.  You can do this for data within a single column or row or an entire data set.

Extend or Shorten a Selection of Data

Shift + Down or Shift + Right or Shift + Left or Shift + Up
Moves a cell or range selection one row or one column to the right, left, up, or down.  This makes it easy to adjust a range selection when you need to remove something like the table headers from the selection.

Select the Entire Current Data Set

Ctrl + * (on U.S. keyboards Ctrl + Shift + 8)
Selects the entire current data set in which you have selected a cell.


Enter the Current Date or Time


Ctrl + ;
Enter the current date into a cell.
Ctrl + :
Enter the current time into a cell.

Enter the Same Value in Multiple Cells at Once

Ctrl + Enter
Select a range of cells or simply many cells throughout the worksheet and then type a value and hit Ctrl + Enter to make that value go into all of the selected cells.

Repeat the Last Task

F4
This will repeat the last task on the current selection.  This is exceptionally helpful when deleting rows and columns.  Delete the first one, select the next one, hit F4, and that's it.

Quickly Create Absolute or Relative References

F4
Use this when entering a formula or function into a cell.  When you get to a cell or range reference in a formula, put the mouse cursor next to that part and hit F4 to cycle through the options of making that reference absolute, with dollar signs, or relative.  If you want to adjust all cell references in the formula or function at once, select all of the contents of the cell before hitting F4.

Note that this cycles through the different variations of absolute and relative; each row and column reference can be absolute or relative separate from the rest of the range reference.  This sounds confusing but play around with it a bit and it should become clear.


Turn Formulas into their Visible Values or Paste as Value

Ctrl + C and then Alt + E + S + V and Enter
This combination of keyboard shortcuts will change the current selection from a formula or function into the visible output that that formula or function generated.

This may not seem important but it will come in very handy.  I use this almost daily, especially when I need to create sample or scratch data.

Notes

These are the top keyboard shortcuts to increase your productivity.  I use almost all of these shortcuts on a daily basis and it makes working in Excel a much more pleasant experience.
I didn't include obvious keyboard shortcuts like cut and paste or save or print because those aren't particular to Excel and you should already know those by now if you are working in Windows.

Friday, January 20, 2017

Arrange and View Multiple Worksheets at Once in Excel

This feature allows you to view multiple worksheets at once from the same workbook at the same time.

 You need to follow beneath simple steps to view multiple worksheets at once from the same workbook at the same time:

  1. Go to the View tab and click New Window

Wednesday, January 18, 2017

Count Specific Errors in excel

Learn, How to count the occurrence of a specific error in a Range of cells in Excel.

Follow beneath steps to Count the number of times a specific error appears in a range.

Select the entire range of cells, for which you want to take the count of error occurrence.
 =COUNTIF(A1:A5,"#NAME?")  

This is NOT an array formula.

A1:A5 is the range to check; change this to fit your data.

#NAME? is the error that you want to count. Change this to the desired error and make sure it is surrounded with quotation marks.



Result:
 



Sunday, January 15, 2017

Count the Errors in a Range of cells in Excel

Learn, How to count the number of errors in a range of cells in Excel:

Follow beneath steps to Count all of the errors that occur in a range of cells:

Select the entire range of cells, for which you want to take the count of error occurrence.

 =SUM(ISERROR(A1:A5)*1)

Array formula: you must enter this into the cell using Ctrl + Shift + Enter or it won't work.

A1:A5 change this to your range of data. That's all you have to do to get this to work for your data.


Result: