Skip to content

Instantly share code, notes, and snippets.

View ship9599's full-sized avatar

John IV ship9599

View GitHub Profile
@ship9599
ship9599 / 0_reuse_code.js
Created November 15, 2016 00:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ship9599
ship9599 / A_Small
Created December 8, 2017 21:36
Send - JES
Sub Small_All()
'Application.ScreenUpdating = False
'Application.Visible = False
Worksheets("Snapshot").Range("C16").Value = ""
Sheet1.Range("A4").Value = "U15154108-23 Client"
Sheet1.Range("A10:Z1000").Clear
PORT_RefDataExample
@ship9599
ship9599 / Auto_Adjust_Column_Width
Last active December 11, 2017 17:39
We can change row height in Excel using RowHeight Property of a Row in VBA. See the following example to do it.
Sub sbAutoAdjustColumnRowWidth()
'Auto ColumnFit
Columns(2).AutoFit
'Auto RowFit
Rows(2).AutoFit
End Sub
@ship9599
ship9599 / Email_Inputs
Last active December 11, 2017 18:41
Text file = sender address.
Sub Email_Inputs()
Dim myFile As String, Text As String, textline As String
Dim D_1 As String, D_2 As String, D_3 As String
Dim email1 As String, pmname1 As String ', senddisplay As String
myFile = "F:\Ultimus_FTP\Script Files\MFTrades_Email_To.txt"
Open myFile For Input As #1
@ship9599
ship9599 / Date_Batch_File
Created December 13, 2017 22:08
This will give you DD MM YYYY YY HH Min Sec variables and works on any Windows machine from XP Pro and later.
@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "datestamp=(%YYYY%.%MM%.%DD%)" & set "timestamp=%HH%%Min%%Sec%"
set "fullstamp=%YYYY%.%MM%.%DD%_%HH%-%Min%-%Sec%"
echo datestamp: "%datestamp%"
echo timestamp: "%timestamp%"
echo fullstamp: "%fullstamp%"
@ship9599
ship9599 / AHK_Dates
Last active January 5, 2018 16:06
Autohotkey Date Examples
:R*?:ddd::
FormatTime, CurrentDateTime,, dd/MM/yy
SendInput %CurrentDateTime%
return
:R*?:xxx::
FormatTime, CurrentDateTime,, yyMMddHHmmss
SendInput %CurrentDateTime%
return
:R*?:aaa::
FormatTime, CurrentDateTime,, yyMMdd
@ship9599
ship9599 / CleanFileName
Last active January 5, 2018 16:07
Outlook Function Snippets (VBA)
'************ CleanFileName(strText As String) As String **********
Function CleanFileName(strText As String) As String
Dim strStripChars As String
Dim intLen As Integer
Dim i As Integer
strStripChars = "/\[]:=," & Chr(34)
intLen = Len(strStripChars)
strText = Trim(strText)
For i = 1 To intLen
REM YTD Parameters***************
REM Set a=$({bdty})
REM Set b=$({toda})
ASK a "Enter a start date in the format mmddyyyy"
ASK b "Enter an end date in the format mmddyyyy"
MESSAGEBOX d ! YesNoCancel 2 "Do you want to run for an individual portfolio? (<> @BIPortfolios)?"
IF "%d" == "cancel" GOTO end
@ship9599
ship9599 / FileExist.vbs
Last active February 6, 2018 15:43
Visual Basic - Functions - FileExist, FileOrDirExists, TestItWithWindows, TestItWithMacintosh
Function FileExist(FilePath As String) As Boolean
'PURPOSE: Test to see if a file exists or not
'SOURCE: www.TheSpreadsheetGuru.com/The-Code-Vault
'RESOURCE: http://www.rondebruin.nl/win/s9/win003.htm
Dim TestStr As String
'Test File Path (ie "C:\Users\Chris\Desktop\Test\book1.xlsm")
On Error Resume Next
TestStr = Dir(FilePath)
@ship9599
ship9599 / AutoHotkey.ahk
Created March 8, 2019 01:02 — forked from endolith/AutoHotkey.ahk
AutoHotkey_L Hotstrings and other utilities
;------------------------------------------------------------------------------
; Disable Insert key
;------------------------------------------------------------------------------
$Insert::return
!Insert::Send, {Insert} ; Use Alt+Insert to toggle the 'Insert mode'
;------------------------------------------------------------------------------
; Hand tool with middle button in Adobe Reader
;------------------------------------------------------------------------------
#IfWinActive ahk_class AdobeAcrobat