Most frequently used piece of VBA

I wish Paste Special included an option to choose whether or not to move references relatively or not...

This is one of the 4 or 5 options that I use ASAP utilities for daily. I couldn't function properly without having the ASAP utlities tool, even though before I knew about the tool, I had quite a few of the options created in my own macros.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I can't think of anything that I use repeatedly in my programming, but a lot of reports I use export to Excel with the dates stored as text. So I find myself using this in the Immediate Window often:
Code:
Selection = Selection.Value
 
Last edited:
I can't think of anything that I use repeatedly in my programming, but a lot of reports I use export to Excel with the dates stored as text. So I find myself using this in the Immediate Window often:
Code:
Selection = Selection.Value
Text to Columns also works very well for this. Click text to columns and then Finish and you are done.
 
I use this a lot:
Code:
Public Function LastCell(wrkSht As Worksheet, Optional Col As Long = 0) As Range


    Dim lLastCol As Long, lLastRow As Long
    
    On Error Resume Next
    
    With wrkSht
        If Col = 0 Then
            lLastCol = .Cells.Find("*", , , , xlByColumns, xlPrevious).Column
            lLastRow = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
        Else
            lLastCol = Col
            lLastRow = .Columns(Col).Find("*", , , , xlByColumns, xlPrevious).Row
        End If
        
        If lLastCol = 0 Then lLastCol = 1
        If lLastRow = 0 Then lLastRow = 1
        
        Set LastCell = wrkSht.Cells(lLastRow, lLastCol)
    End With
    On Error GoTo 0
    
End Function

After that it's code for creating folders, getting all files of a certain type, and then it's .... I don't know, I've got hundreds of .bas files saved that I can just drag and drop into projects. Just need to index them and give them a better naming convention - now did I call that file GetLastCell, FindLastCell or just LastCell?
 
I like this one for putting files on my desktop (typically, some kind of temporary file):
Code:
Dim myDesktopFolder as string
myDesktopFolder = CreateObject("WScript.Shell").SpecialFolders("Desktop")

However, my desktop has very little on it. That may be unusual!

Some routines I use every day are:
Putting light grey borders around cells
Setting my default fill color for "input cells"
Cleaning up Access import data (removing the wrap text option that comes with it)
Custom keyboard shorts: hard copying text, unfiltering filtered data, backing up a file, toggle manual/auto calculation, toggle show grid lines, toggle cursor direction after enter/tab.

Other generic routines are on my right click menu (which is heavily customized, as it my ribbon and QAT):
http://www.mrexcel.com/forum/excel-...izing-excel-right-click-menu-still-works.html
As a result of the keyboard shorts, ribbon customizations, and QAT I use Excel with the Ribbon minimized and don't actually have to use the ribbon very much except when designing new spreadsheets or building charts.

Don't we have a thread like this somewhere else already?
 
Another nice trick I found described here (disabling the blasted help dialog from popping up unintentionally):
http://www.mrexcel.com/forum/excel-questions/723709-always-hitting-f1-when-i-mean-hit-f2-print.html

Good idea! I don't tend to hit it accidentally too often but what does annoy me is when I do something that produces an error message and the default button is the help button! Circular references for instance - hit ENTER to dismiss the message and it actually loads the help. That really annoys me!
 

Forum statistics

Threads
1,223,727
Messages
6,174,139
Members
452,546
Latest member
Rafafa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top