Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

14 total results found

Excel VBA

Python

SAS

Excel Formulas

Get current user name

Excel VBA

For a computer that is not joined to a domain (Computer Username) Sub Get_Username() 'Get the environment username Dim UserName As String UserName = Environ$("UserName") MsgBox "Hello " & UserName End Sub For a computer that is joined to a domain (Domai...

Add Worksheet if it does not exist

Excel VBA

Add a worksheet titled "Data" if it doesn't exist and ignore adding if it already exists Sub Add_Worksheet() Dim i As Long For i = 1 To Worksheets.Count If Worksheets(i).Name = "Data" Then SheetFound = True End If Next i If Not SheetF...

High Precision Timer using Windows API

Excel VBA

High Precision Timer using Windows API Private Declare PtrSafe Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long Private Declare PtrSafe Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Lon...

Get user desktop and make a folder

Excel VBA

Get user desktop and make a folder Dim DeskTop As String Dim WSH As Object Dim GetDesktopPath As String Dim MainFolder As String Set WSH = CreateObject("WScript.Shell") DeskTop = WSH.SpecialFolders("desktop") GetDesktopPath =...

Delete a worksheet

Excel VBA

To delete a worksheet titled "Data" Sub DeleteSheet() Application.DisplayAlerts = False 'Replace "Data" with your sheet name Sheets("Data").Delete Application.DisplayAlerts = True End Sub

Detect OS Type

Excel VBA

Used to detect if OS Type is Windows or macOS Sub GetOSType() 'Get the OS that I am running from Dim OSType As String OSType = Application.OperatingSystem If OSType Like "*Windows*" Then OSType = "Windows" Else ...

Writing to CSV

Python

To write to a CSV file import csv header = ['name', 'area', 'country_code2', 'country_code3'] data = ['Afghanistan', 652090, 'AF', 'AFG'] with open("C:\\Users\\Nicholas Goh\\Desktop\\test.csv", 'w', encoding='UTF8', newline='') as f: writer = cs...

Creating and calling a Function

Python

Single Argument def AFunctionSample(SampleArg): print(SampleArg) AFunctionSample("Hello World!") Multiple Arguments def AFunctionSample(SampleArg1, SampleArg2): print(SampleArg1 + SampleArg2) AFunctionSample("Hello World!", " It's Me!")   Note: ...

Taking a screenshot

Python

Full Screen import pyautogui pyautogui.screenshot("C:\\Users\\Nicholas Goh\\Desktop\\test.png") Specific areas to screenshot can be specified by using the Region argument import pyautogui pyautogui.screenshot("C:\\Users\\Nicholas Goh\\Desktop\\test.pn...

Generating a Timestamp

Python

To generate a timestamp from datetime import datetime TimeStamp = datetime.now().strftime("%Y%m%d-%H%M%S") print(TimeStamp) %Y Year in yyyy %y Year in yy %m Month in mm %d Day in dd %H Hour in HH %M Minute in MM %S Seconds in SS