Showing posts with label Macro. Show all posts
Showing posts with label Macro. Show all posts

Saturday, December 21, 2013

Top Excel Help Posts in 2013 and 2014 Goals

2013 is coming to a close so it’s that time of year to sit back and reflect about what transpired this past year and what is to come. I’m going to share my most popular Excel tips from the past year, my most popular Excel templates, and finally share what my goals and vision for next year is.

Top 5 Excel Tips from 2013

 
Listed below are the five most popular Excel tips I published on the Excel Help blog throughout 2013:
 
 

Top 5 Excel Templates from 2013

 
Listed below are the top 5 most popular free Excel templates and spreadsheets I created and made available to download in 2013:
 
 

Goals for 2014



I recently took a poll of my loyal followers by asking them what they would rather see more of on the blog: spreadsheet templates or tips/tricks/macros to improve spreadsheet creation efficiency? My most recent posts have primarily been spreadsheet templates I’ve made available to download for free, such as my newborn feeding schedule, college bowl prediction pool, etc. Something I’ve gotten away from lately is posting tips and macros to improve your Excel efficiency, like my earlier posts on how to create folders automatically, how to create hatching in Excel, etc.


The majority of my reader’s responses asked for more tips, tricks, and macros to improve Excel efficiency. I will still be creating and posting templates as I have been because I think a lot of people find them to be quite useful and you may pick up a few tips just by looking at them and examining the formulas I use. However, I promise to make a strong effort to post more tips and macros, especially for my email subscribers. In fact, I already have several rough drafts already written and am working on some new video tutorials. What would you like to see more of in 2014? Anything specific?


Have a great holiday season, thanks for your continued support, and see you in 2014!!!





Monday, September 23, 2013

How to Combine Excel Files

There have been countless times during my day job when I’ve had to combine multiple Excel files into one. I used to do it the old fashioned way of copy and paste but after doing this tedious and time consuming task I decided to write a VBA macro to help me out. I’ve now made the template available for you to use for free. This version of the combine Excel workbooks macro allows you to choose the directory of the Excel files to copy without having to change the code in the Visual Basic Editor. The steps to use the Combine Workbooks tool are as follows:

combine excel files macro
 
  1. Place the Excel workbooks you want to combine into a single folder that contains no other files
  2. Go to View>Macros
  3. Select "Combine Workbooks" then click Run
  4. Select the File where the spreadsheets you want to combine are located
  5. Save the newly created file

Instructions are provided with the spreadsheet

Please note that this code will not work on protected sheets and it will automatically skip any blank worksheets in any of the workbooks saved in the folder. See how it works for yourself by watching my short demo video below:
 

 
Download the Combine Excel Files spreadsheet that contains the VBA code to copy all the worksheets from all the workbooks in a folder into the active workbook using this link:
 

Combine Files.xlsm download

Tuesday, September 10, 2013

Download a Wordpress Website Creation Checklist Spreadsheet

In the past two years I’ve created eight websites for various hobbies and niches I am interested in and that I felt were underserved in the online world. I use Wordpress as my content management system because it allows you to quickly create a website with no HTML or other coding experience. The steps to setup a new website are pretty much the same so I put together a Wordpress website creation checklist to help me remember to do everything. I’ve made this checklist into an Excel template which you can download for free by clicking the link below.
 
wordpress website creation checklist
 
Two skills I encourage everyone to learn that I’ve found invaluable in my career is how to program VBA macros and how to build a simple website. In fact, in one of my most recent projects these skills were used hand-in-hand. I built the majority of the Observation Wheel database with an Excel spreadsheet and a few custom macros. Every row in my sheet contained all the information for a single observation wheel. I then had the macro export the data to Microsoft Word in the HTML format I needed for the site. I then simply copied and pasted that text into Wordpress and published it. I created pages for over eighty dfferent observation wheels almost instantly!
 
There are countless positive benefits for learning how to make a website. I’ve included a link to all the resources I use within the template and I've tried to include as many tips as I could think of. I begin with registering a domain name and take you all the way through setting up an email list. Download my Wordpress website creation checklist below and please feel free to ask me any questions you may have!
 

Thursday, June 6, 2013

Excel Pranks and Practical Jokes with VBA

I’ve shared a lot of Excel tips about how to increase your productivity at work but today I thought I would post something a little more fun – how to decrease your productivity! I’m talking about ways to use Microsoft Excel spreadsheets to play pranks, practical jokes, April Fool’s Day kind of stuff on your friends, roommates, and coworkers. The intent is not to harm anyone or hurt their professional careers – this is simply about having some plain ole fun.

A great way to wreak havoc in the workplace is to create a macro that automatically runs when an Excel workbook is opened. You can do this by writing a VBA procedure in the Open event of the workbook by using the Visual Basic Editor. Create a new Excel spreadsheet then press Alt+F11 to launch the VBA Editor. Next, right-click the ThisWorkbook object, and then click View Code.
excel pranks
 
In the Object list above the Code window, select Workbook. This will automatically create an empty procedure for the Open event like this and you can now add your evil code.

excel practical jokes
 
To make Excel automatically close itself when the workbook is opened use this:

Private Sub Workbook_Open()
     Application.DisplayAlerts = False
     Application.Quit
End Sub
 

Here’s a trick that will automatically open Microsoft Word and close Excel:

Sub Workbook_Open()
‘make sure the Microsoft Word Object Library is selected by going to tools>references
Application.Visible = False
Dim wdApp as Word.Application
Set wdApp = New Word.Application
wdApp.Visible=True
Set wdApp = Nothing
Application.DisplayAlerts = False
Application.Quit
End Sub
 

This is one of my personal favorites; have a message box pop-up asking if the user wants to download the virus they requested. Whether they press the yes or no button the next message tells them the virus has begun downloading!

Private Sub Workbook_Open()

MsgBox "The virus you requested is now ready to download, Do you want to start downloading now?", vbYesNo, "Virus Trojan-x45fju"

MsgBox "The Virus is Now Downloading. You have made the biggest mistake of your life! ByE bYe", , "Begin Virus Download"

End Sub

This function flips the workbook and will make everything on the left now appear on the right side:

ActiveSheet.DisplayRightToLeft = True

To change all cell’s color to black:

Cells.Interior.Color = RGB(0,0,0)

Instead of automatically running a macro on opening a workbook (and making it obvious you did something) you could embed a macro that only runs on certain conditions. A funny prank is a macro to change the size of the Excel window every time the user clicks on a cell:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Application.WindowState = xlNormal

Application.Width = Int(Rnd() * 1000) - 100

End Sub

 

As you can imagine, the possibilities are nearly endless! Now you may think “All someone has to do is change or delete the code to fix the problem.” Well, you can protect your VBA code so only those with the password can modify it. Go to Tools>VBAProject Properties>Protection. Check the box to lock project for viewing and create a password (and remember it). Now you’re an evil genius!

 


Of course, if you’re not comfortable using VBA (which I recommend you get comfortable and learn it)  you can always use these old fashioned tricks:

  1. Use find and replace on a document, like replacing “you” with “you idiots”.
  2.  If your coworker has an old school mouse simply remove the ball when they're not around and then sit back and watch the fun when they try to figure out why their mouse isn't working anymore.
  3. Take a screen capture of a roommate’s desktop and save it as a jpg or bmp file. Turn on the Active Desktop, and make sure to turn off "show desktop icons". Change the wallpaper to the screen capture image you just saved and watch as they click away on their "icons" that mysteriously stopped working.

Have you ever used something like this on someone? What’s your best Excel prank?

Tuesday, April 16, 2013

Unique Excel Uses: Video Game

We’ve seen some very unique Excel uses in the past but this just might be the best (or most fun) application: Excel as a video game! Cary Walkin, a Canadian accountant, has transformed a Microsoft Excel spreadsheet into a playable video game. Arena.xlsm is a turn-based fantasy role playing game where the goal is to collect loot to become more powerful all the while warding off increasingly difficult  monsters. In fact, there are currently over 2000 possible enemies with different AI abilities. Sounds complex! Remarkably, it only took Cary four months to completely program this game.

arena xlsm excel as video game


Cary has received a lot or press and attention since creating his Excel game. Recently, he was featured on one of Reddit’s “I Am A” features. A few quotes from Cary:

“I'm an accountant by profession, I use excel every day of my life. I simply worked with what I knew. Also there is an old adage that underneath every RPG is a massive spreadsheet, so now the massive spreadsheet IS the RPG!”

“...a number of calculations are dependent on the background colour of a cell (such as if you are standing on fire).”

“Never stop learning.”


Read the entire interview feature here. Additionally, to see an example of how one would even begin to go about coding this massive gaming macros see Cary’s great VBA tutorial here.

Visit Cary’s site and download Arena XLSM today and try it out for yourself! But be warned, your productivity may decrease greatly after playing a few levels.  Please note you must have macros enabled in order to play the game. Arena.Xlsm will only work in Excel 2007, 2010 and 2013. It will not work in other spreadsheet programs either. Have fun!

-Nick
Of course I’m not playing this at work ;)

Tuesday, March 5, 2013

Macro to Export Hyperlinks from Excel to Word


In this tutorial I am going to show you how to write a VBA macro to export hyperlinks from Excel to Word. I’m all about automation and efficiency and this is another real world example. I used this macro to quickly create a table of the world’s observation wheels for my latest website.

What you will learn by reading through this tutorial:

  • How to create a VBA macro to send data from Excel to Word
  • How to export hyperlinks from Excel
  • How to find the last row of data in an Excel sheet using a macro
  • How to paste hyperlink into Word using a macro
  • How to make a webpage from an Excel file

To begin, we have an Excel sheet with names in column A, some of them are hyperlinks to webpages and some of them are not. Hit Alt + F8 and create a new macro, I named mined Tables. It’s time to begin coding.
 
export hyperlinks from excel to word

 

The first thing we need to do is create a new instance of Microsoft Word and make it visible:

 

Dim appWD As Word.Application

Set appWD = CreateObject("Word.Application")

appWD.Visible = True

 

Next, let’s find the last row that contains data within our active Excel spreadsheet (my sheet is called “Data”):

 

Sheets("Data").Select

            Dim FinalRow As Integer

 

            FinalRow = Range("A9999").End(xlUp).Row

 

Now we add some error handling - if there is no data then quit the program, otherwise continue on:

If FinalRow = 0 Then

            Exit Sub

 

            Else

 

As a check, I like to have a message box pop-up displaying the total number of rows with data:

 

            MsgBox "Number of rows is " & FinalRow

 

Now it’s time to tell Word to create a new document. We’ll also add our header text by using TypeText. TypeParagraph inserts a new paragraph by going to the next line:

 

            appWD.Documents.Add

            appWD.Selection.TypeParagraph

 

            appWD.Selection.TypeText Text:="[table caption= List of Observation Wheels]"

 

            appWD.Selection.TypeParagraph

 

            appWD.Selection.TypeText Text:="Name,Height(m)"

Next, we’ll create a For...Next loop to cycle through every row and look to see if there is a hyperlink in column A. If there is a hyperlink, we want to copy it, if not then we still want to copy any text in the cell.

 

Dim hyperlink1 As String

Dim i As Integer

 

            For i = 2 To FinalRow

 

            If Range("A" & i).Hyperlinks.Count > 0 Then

 
 

            'if there is a hyperlink

 

            appWD.Selection.TypeParagraph

 

            hyperlink1 = Range("A" & i).Hyperlinks(1).Address

 

            appWD.ActiveDocument.Hyperlinks.Add Anchor:=appWD.Selection.Range,          Address:=hyperlink1, SubAddress:="", ScreenTip:="", TextToDisplay:=Range("A" & i)

 

            appWD.Selection.TypeText Text:="," & Range("B" & i)

 
 

            Else

 
 

            'If no hyperlink

 

            appWD.Selection.TypeParagraph

 

            appWD.Selection.TypeText Text:=Range("A" & i) & "," & Range("B" & i)

 
 

            End If

 

            Next 'i

 

Finally, we can add any text at the bottom of the document and close the if and sub statements.

 

            'end the table

            appWD.Selection.TypeParagraph

            appWD.Selection.TypeText Text:="[/table]"

            End If

            End Sub

create webpage from excel with macro
 

You may have noticed I began and ended with [table] and [/table]. I installed a Wordpress plugin on my website that enables me to easily insert sortable tables into my webpage without any major html coding involved. So now I can run my macro on my spreadsheet, copy the result it spits out into Word, and paste the text into my website. Here is the end result, a sortable table of all large observation wheels found throughout the world! Pretty cool huh?
Related Posts Plugin for WordPress, Blogger...