Skip to content

Instantly share code, notes, and snippets.

View Se7enSquared's full-sized avatar
🐍
import this

HGray Se7enSquared

🐍
import this
View GitHub Profile
'EXAMPLE CALL:
' To clipboard:
' Dim string_to_copy As String: string_to_copy = ThisWorkbook.Worksheets("Sheet1").Range("A1").Value
' Clipboard (string_to_copy)
' From clipboard:
' Dim in_clipbaord As String
' in_clipboard = Clipboard()
'------------------------------------------------------------------
' Function: Clipboard
' Purpose: Read from (if no variable passed) or write variable
Public Sub CopyUsedRangeFromExternalWBToTable(source_ws_number As Long, wb As Workbook, dest_sheet As String, dest_range As String)
wb.Worksheets(source_ws_number).UsedRange.Copy
ThisWorkbook.Worksheets(dest_sheet).Range(dest_range).PasteSpecial Paste:=xlPasteValues
End Sub
' ----------------------------------------------------------------
' Function: ChooseExcelFile
' Purpose: Get the location of the chosen excel file from dialog
' Params: String: starting_path: The folder to open the dialog in
' example: Environ$("USERPROFILE") & "\Downloads" or
' example2: C:\Data (no ending \)
' Returns: String: The full path to the chosen excel file as string
' By: HG
' Date: 12/21/2021
' ----------------------------------------------------------------
Private Sub DateStampCell(stamp_rng As Range, worksheet_list As Collection)
On Error GoTo catch_error:
For Each sht In worksheet_list
stamp_rng.Value = "Last Updated: " & Now & " Data since: " & [LastRunDate]
Next sht
Exit Sub
catch_error:
'-------------------------------------------------------------
' Sub: SendEmail
' Purpose: Sends an email through Outlook
' Params:
' Subject: String: email subject
' to_list: Stirng: semi-colon seperated list of recipients
' cc_list: String: semi-colon seperated list of cc
' body: String: email body
' Last Update: 3/5/2021
' Author: Gray
Function SplitBasic(str As String, sep As String)
Dim arr() As String
Set SplitBasic = Split(str, sep)
End Function
def build_character_seperated_string_from_pd_series(series):
"""iterates through a pandas series (column) and creates comma seperted string from the values
Returns:
string: a comma seperated list of values in the series as a string
"""
str1 = ''
for cell in series:
str1 = str1 + cell + ";"
return str1[:-1]
C:\directory_where_ui_file_is\> python -m PyQt5.uic.pyuic -x form.ui -o form.py
Private Sub ClearAllFilters()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.ShowAllData
Next ws
End Sub
Function ValueInTable(ByVal column_number As Long, ByVal tbl As ListObject, ByVal LookupValue As String) As Boolean
Dim FoundCell As Range
'Attempt to find value in Table's first Column
On Error Resume Next
Set FoundCell = tbl.DataBodyRange.Columns(column_number).Find(LookupValue, LookAt:=xlWhole)
On Error GoTo 0
'Return Table Row number if value is found