Skip to content

Instantly share code, notes, and snippets.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : Sheet, the worksheet we'll search to find the last row
'OUTPUT : Long, the last occupied row
'SPECIAL CASE: if Sheet is empty, return 1
'EXAMPLES :
'
'assume that there is a single
'entry on MySheet in cell A5:
'
'LastRowNum(MySheet)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : True or False (i.e. fast or slow)
'DESCRIPTION : this sub turns off screen updating and alarms then
' sets calculations to manual
'
Public Sub GoFast(OnOrOff As Boolean)
Dim CalcMode As XlCalculation
CalcMode = Application.Calculation
With Application
.ScreenUpdating = Not OnOrOff
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : Sheet, the worksheet we'll search to find the last column
' : RowNum, the row (as a number) we're interested in
'OUTPUT : Long, the last occupied column in the specified row
'SPECIAL CASE : if a bad row number is entered (anything < 1), return 0
'EXAMPLES BELOW:
'
'assume that on MySheet, cells A1:F1 are occupied,
'but B3 is the only occupied cell in row 3
'LastColNumInRow(MySheet, 3)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : Sheet, the worksheet we'll search to find the last column
'OUTPUT : Long, the last occupied column
'SPECIAL CASE : if Sheet is empty, return 1
'EXAMPLES BELOW:
'
'assume that there is a single entry on MySheet in cell C3
'LastColNum(MySheet)
'>> 3
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : Sheet, the worksheet we'll search to find the last column
' : RowNum, the row (as a number) we're interested in
'OUTPUT : Long, the last occupied column in the specified row
'SPECIAL CASE : if a bad row number is entered (anything < 1), return 0
'EXAMPLES BELOW:
'
'assume that on MySheet, cells A1:F1 are occupied,
'but B3 is the only occupied cell in row 3
'LastColNumInRow(MySheet, 3)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : SheetName, the name (string) of the sheet we're looking for
'OUTPUT : True or false (sheet was found, sheet was not found)
'SPECIAL CASE : none
'EXAMPLES BELOW:
'
'assume that a sheet named "YaGotMe" exists
'DoesSheetExist("YaGotMe")
'>> True
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : Sheet, the worksheet on which you'd like all filters cleared
'DESCRIPTION : this sub will remove all filters on a worksheet safely
'
Public Sub ClearAllFilters(Sheet As Worksheet)
With Sheet
.AutoFilterMode = False
If .FilterMode = True Then
.ShowAllData
End If
@danwagnerco
danwagnerco / _vimrc
Last active June 11, 2021 09:28
A starter _vimrc file for Vim 8.0 and vim-plug on Windows 10
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
@danwagnerco
danwagnerco / _vimrc
Last active August 29, 2015 14:12
Airline-specific _vimrc settings
set guifont=Meslo\ LG\ M\ for\ Powerline:h9 " <~ set the font
set encoding=utf-8 " <~ set the encoding
let g:airline_powerline_fonts=1 " <~ activate the font in airline
@danwagnerco
danwagnerco / _vimrc
Last active August 29, 2015 14:13
Consolas setting for vim-airline inside your _vimrc
" set guifont=Meslo\ LG\ M\ for\ Powerline:h9 " <~ set the font
set guifont=Powerline\ Consolas:h11 " <~ set the font
set encoding=utf-8 " <~ set the encoding
let g:airline_powerline_fonts=1 " <~ activate the font in airline