This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Sub ScatterPlotter() | |
'This VBA Excel code formats a three-column table (with header, data labels on lefter-most column) into a format suitable for creating a scatter diagram in Microsoft Excel / PowerPoint. | |
If MsgBox("When you begin, ensure that: (1) Col A is populated with desired horizontal labels, begin from A2 (downwards); (2) Col B is populated with desired x-axis values, begin from B2 (downwards); (3) Col C is populated with desired y-axis values, begin from C2 (downwards). Do you wish to continue?", vbYesNo) = vbNo Then Exit Sub | |
Dim activewb As Workbook | |
Dim origin_sheet As String | |
Dim oldsheet, newsheet As Worksheet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Collater() | |
'You will have a two-column data table (with headers) and as many rows as you want. | |
'It doesn't matter whether your data consists of text or number - no "calculation" is run directly on the values. | |
'You want to "multiply out" your data to get all possible combinations. | |
'Ordering: Column A for the variable to repeat multiple times (e.g. Alice, Alice, Alice, Bob, Bob, Bob) | |
'Ordering: Column B for the variable to display in sequence (e.g. 15, 20, 30, 15, 20, 30) | |
'Leave first row blank | |
Dim wb As Workbook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub DArrayCreator() | |
Dim wb As Workbook | |
Dim ws As Worksheet | |
Dim i, j, k As Integer | |
'Use this snippet for creating dynamic arrays from rows of data in Excel. | |
'Current snippet only allows for two columns of data. | |
'Enter source workbook location here | |
'Set wb = Workbooks.Open("C:\Users\Martin\Desktop\ArrayReplacer.xlsx") | |
Set wb = ActiveWorkbook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub CommandButton1_Click() | |
Dim month_a, month_b, month_c, j As Integer | |
Dim currentm, defaultm As Long | |
Dim pvt As PivotTable | |
Dim coll As Collection | |
Dim PivotRefs, i As Variant | |
Application.ScreenUpdating = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# installing/loading the package: | |
if(!require(installr)) { | |
install.packages("installr"); require(installr)} #load / install+load installr | |
# using the package: | |
updateR() # this will start the updating process of your R installation. It will check for newer versions, and if one is available, will guide you through the decisions you'd need to make. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("tm") | |
library("wordcloud") | |
library("SnowballC") | |
library("RColorBrewer") | |
library("tcltk2") | |
tk_choose.dir(getwd(),"Choose a suitable folder") | |
db = file.choose() | |
data <-read.csv(db,stringsAsFactors = FALSE) | |
#Create text corpuses for Promoters and Detractors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("rvest") | |
url <- "https://bank.hangseng.com/1/2/rates/foreign-currency-tt-exchange-rates" | |
#Replace xpath with bits highlighting whole table on website using 'Inspect' | |
forex <- url %>% | |
html() %>% | |
html_nodes(xpath='//*[@id="viewns_7_0G3UNU10SD0MHTI7BJ91000000_:Display"]/div[1]/table') %>% | |
html_table() | |
forex <- forex[[1]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub parse_data() | |
Dim lr As Long | |
Dim ws As Worksheet | |
Dim vcol, i As Integer | |
Dim icol As Long | |
Dim myarr As Variant | |
Dim title As String | |
Dim titlerow As Integer | |
'This macro splits data into multiple worksheets based on the variables on a column found in Excel. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub SaveWorksheetsAsCsv() | |
Dim WS As Excel.Worksheet | |
Dim SaveToDirectory As String | |
Dim CurrentWorkbook As String | |
Dim CurrentFormat As Long | |
CurrentWorkbook = ThisWorkbook.FullName | |
CurrentFormat = ThisWorkbook.FileFormat |
OlderNewer