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 normalise() | |
Dim rng, cel As Range | |
Set rng = Application.InputBox("Please select source range area (exclude headers)", "Source data", Default:="=$A$3:$G$10", Type:=8) | |
Dim max, min As Long | |
max = Application.max(rng) | |
min = Application.min(rng) | |
Debug.Print max | |
Debug.Print min |
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 Combine() | |
Dim Acc_Name As Variant | |
Dim i As Long | |
Dim j As Integer | |
Dim newsheet As Worksheet | |
On Error GoTo Errorcatch | |
Acc_Name = Array("CLloyds", "NFQ", "SSaver", "CISA", "CLMSaver") |
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
#readClipboard() | |
#Read copied folder path as something that R can read in properly | |
library(readxl) | |
library(tidyverse) | |
library(stringr) | |
library(forcats) | |
setwd("C:\\Users\\Martin.Chan\\Desktop\\R workdesk\\missing values") | |
add.dt<-read_excel("ORD-272769-F4S6 - Additional info for UK.xlsx",sheet="Additional info",na="NA") |
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 Format_a_Chart() | |
'r converts cm to points | |
r = 28.3464567 | |
Dim shp1 As Shape | |
Dim i, j, k As Long | |
Set shp1 = ActiveWindow.Selection.ShapeRange(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
str_replace_n <- function(x, pattern, replace, n){ | |
g <- gregexpr(pattern,x)[[1]][n] | |
output <- paste0(substr(x,1,g-1),replace,substr(x,g+1,nchar(x))) | |
output | |
} | |
str_replace_n("ALLAHABAD","A","U",3) | |
#[1] "ALLAHUBAD" | |
str_replace_nth <- function(x, pattern, replacement, n) { |
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 table_tinkerer_threetabs() | |
'Table tinkerer tool created for three tables iterated across many slides | |
'Alt+F11 to start up code module | |
'Insert New Module >> | |
'Select Table >> Run |
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 ScatterLabelsTweak() | |
Dim sld As Slide | |
Dim shp As Shape | |
Dim sr As Series | |
Dim chrt As Chart | |
Dim i, j, k, m As Long | |
For Each sld In ActivePresentation.Slides | |
For Each shp In sld.Shapes |
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
match_counter <- function(df,target){ | |
arguments <- as.list(match.call()) | |
targ <- deparse(substitute(target)) #variable to string | |
#Produce a data frame of all columns on whether they match values of target column | |
df %>% | |
mutate_all(funs(.==eval(parse(text=targ)))) %>% | |
colSums(na.rm = TRUE) %>% data.frame() %>% | |
rownames_to_column() -> matches |
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 TimeStamp() | |
time_stamp = Format(DateTime.Now, "yyyyMMdd_hhmmss") | |
Debug.Print time_stamp | |
End Sub |
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
Q12 <- data.frame(num=1:2000,type=sample(c("Sandwich","Porridge","Muesli/cereal","Other","No breakfast"),2000, | |
replace=TRUE,prob=c(0.2,0.15,0.25,0.15,.25))) | |
glimpse(Q12) | |
#All columns as character | |
Q12 %>% | |
mutate_all(funs(as.character)) %>% | |
glimpse() | |