Skip to main content

Automatically run a macro when opening an Excel file

Excel Macros in VBA are really a great way to do repetitive or an automated task. So if you have a specific macro that you'd like to be run every time a specific file is opened, then you need to write the VBA code for that macro in the Workbook_Open() procedure.

Follow the following steps to do that:

Open the Visual Basic editor from the Developer Tab. (Go to the following link if you can't see the Developer Tab)
  1. Look for "This workbook" in the Project Explorer and double-click it.
  2. Select Workbook from the 1st drop-down
  3. Select Open from the 2nd drop-down for excel to automatically create a procedure for Workbook_Open().
  4. Insert the VBA code that you want to run every time the specific excel file is opened.
Microsoft Visual Basic for Applications

There are many other similar procedures that you can add in "This Workbook" like BeforeClose, BeforeSave, Sheet Change etc..,

Comments

Popular Posts

Power Query - "SUBSTITUTE" Function: Remove/Replace multiple values in a column in One Step.

Often times, when you get data from a source, there will most probably be something incorrect that needs to be fixed using an ETL process of Power Query. And most of those transformations would require either Replacing or Removing string's that are not necessary. For example, if you extract any financial data from a source which has multiple currency symbols, there's a chance that the numbers get extracted along with the currency symbols like "$700"/"€700" instead of 700. And these type of cases makes it tough to Transform the Data to our wish as the value will be considered as a text instead of a number. In those type of cases, we would most likely have to create multiple steps to remove the multiple currency symbols from the Column. But thanks to the solution provided by Marcel for one of the questions posted on Stack Overflow, with a little manipulation of the Query language (M), we can replace/Remove multiple strings in one step using the List. ...

Scribble on your PC/Mac screen with these annotation tools

     While you are in a presentation or hosting a webinar, you might want to write/highlight a part of your screen to draw the attention of your audience on something important. Although you can use the tools from powerpoint to scribble in the PPT file, you might want to write something on other apps as well.      That's where these awesome apps come into play. Although these apps have similar features, you might prefer one above the other. ZoomIt :       ZoomIt is an application developed by Microsoft which can be installed from the following link . It is a free tool with features like Text, Shapes, whiteboard, blackboard, zoom . When activated, the tool converts the current screen into a static image and allows you to draw/write on it. One the tool is activated, you can also choose to create a whiteboard/blackboard screen on your PC to draw on. Although the colors are limited to 6 colors: Red (R) , Green (G) , Blue (B) , Orange (O...

Grasshopper: offsetting curves on surface vs scaling curves on surface

Though in Grasshopper Offset and Scale are two different node functions, when it comes to a planar surface, the results of the both are similar. But, I found the " Scale" node to be effective when you want to loft the resultant curve with another. The following images show the different results of a Voronoi structure that yielded when scale and offset nodes are used. When the Offset node is used When Scale is used

Grasshopper: Voronoi Holes on a Planar surface

One of the best natural examples for a Voronoi is the Wing structure of a dragon fly.Grasshopper can help us to build a shape like this in Rhino. Image Courtesy:  The Pond blog Grasshopper by default has a node for Voronoi, we just have to prepare the necessary information to feed into the node. The following example shows how to create a Voronoi shaped holes in a surface Create a planar  Surface  from rhino or grasshopper Randomly Populate the surface with points using the  Populate 2D  Node Feed the surface and the points into the  Voronoi  node and feed a number slider too to adjust eh radius This forms the required Voronoi structure which you can edit the number of points or radius. To create the holes we need to offset each and every inner portion towards its centre using the  Scale  node We can find the centre of each of the inner portions using Area node I'm not sure why but using the offset command su...