Running autofilter VBA macro that has a pop up to enter date
I am a bit new to this whole VBA/Excel Macros thing so I am trying my best to find the solutions I need, so far I've done well - but finally hit a dead-end.
I have a code that is AutoFiltering my data table, and then Sorting base off specific columns (see below).
Sub FGReport()
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=2, Criteria1:= "1085"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=4, Criteria1:= "<>$0"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=6, Criteria1:= "<1/1/2018", Operator:=xlAnd
'ActiveWorkbook.Worksheets("Sorted Report FG").Range("Table25[[#Headers],[LastSoldDate]]").Select
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Clear
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[LastSoldDate]"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[TotalInventoryValue]"), SortOn:= xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Where the code is auto filtering the date (Line 4). I would like it to prompt the user to enter the date manually. I figured doing this with a UserForm would be the most appropriate (picture below)
I just have no clue how to prompt the UserForm to appear during that line of the code, and have it function by entering the date, clicking Enter, and then continue running the original FGReport() macro.
Let me know if more information is needed! Thanks!
excel vba button user-input userform
add a comment |
I am a bit new to this whole VBA/Excel Macros thing so I am trying my best to find the solutions I need, so far I've done well - but finally hit a dead-end.
I have a code that is AutoFiltering my data table, and then Sorting base off specific columns (see below).
Sub FGReport()
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=2, Criteria1:= "1085"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=4, Criteria1:= "<>$0"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=6, Criteria1:= "<1/1/2018", Operator:=xlAnd
'ActiveWorkbook.Worksheets("Sorted Report FG").Range("Table25[[#Headers],[LastSoldDate]]").Select
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Clear
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[LastSoldDate]"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[TotalInventoryValue]"), SortOn:= xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Where the code is auto filtering the date (Line 4). I would like it to prompt the user to enter the date manually. I figured doing this with a UserForm would be the most appropriate (picture below)
I just have no clue how to prompt the UserForm to appear during that line of the code, and have it function by entering the date, clicking Enter, and then continue running the original FGReport() macro.
Let me know if more information is needed! Thanks!
excel vba button user-input userform
Welcome to Stack Overflow! Next time, when adding a code snippet, highlight all of your code and press Ctrl + K on your keyboard to properly format it. Cheers!
– dwirony
Nov 20 '18 at 17:30
add a comment |
I am a bit new to this whole VBA/Excel Macros thing so I am trying my best to find the solutions I need, so far I've done well - but finally hit a dead-end.
I have a code that is AutoFiltering my data table, and then Sorting base off specific columns (see below).
Sub FGReport()
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=2, Criteria1:= "1085"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=4, Criteria1:= "<>$0"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=6, Criteria1:= "<1/1/2018", Operator:=xlAnd
'ActiveWorkbook.Worksheets("Sorted Report FG").Range("Table25[[#Headers],[LastSoldDate]]").Select
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Clear
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[LastSoldDate]"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[TotalInventoryValue]"), SortOn:= xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Where the code is auto filtering the date (Line 4). I would like it to prompt the user to enter the date manually. I figured doing this with a UserForm would be the most appropriate (picture below)
I just have no clue how to prompt the UserForm to appear during that line of the code, and have it function by entering the date, clicking Enter, and then continue running the original FGReport() macro.
Let me know if more information is needed! Thanks!
excel vba button user-input userform
I am a bit new to this whole VBA/Excel Macros thing so I am trying my best to find the solutions I need, so far I've done well - but finally hit a dead-end.
I have a code that is AutoFiltering my data table, and then Sorting base off specific columns (see below).
Sub FGReport()
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=2, Criteria1:= "1085"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=4, Criteria1:= "<>$0"
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Range.AutoFilter Field:=6, Criteria1:= "<1/1/2018", Operator:=xlAnd
'ActiveWorkbook.Worksheets("Sorted Report FG").Range("Table25[[#Headers],[LastSoldDate]]").Select
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Clear
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[LastSoldDate]"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort. SortFields.Add2 Key:=Range("Table25[TotalInventoryValue]"), SortOn:= xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sorted Report FG").ListObjects("Table25").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Where the code is auto filtering the date (Line 4). I would like it to prompt the user to enter the date manually. I figured doing this with a UserForm would be the most appropriate (picture below)
I just have no clue how to prompt the UserForm to appear during that line of the code, and have it function by entering the date, clicking Enter, and then continue running the original FGReport() macro.
Let me know if more information is needed! Thanks!
excel vba button user-input userform
excel vba button user-input userform
edited Nov 20 '18 at 18:04
IREVEL
asked Nov 20 '18 at 17:08
IREVELIREVEL
11
11
Welcome to Stack Overflow! Next time, when adding a code snippet, highlight all of your code and press Ctrl + K on your keyboard to properly format it. Cheers!
– dwirony
Nov 20 '18 at 17:30
add a comment |
Welcome to Stack Overflow! Next time, when adding a code snippet, highlight all of your code and press Ctrl + K on your keyboard to properly format it. Cheers!
– dwirony
Nov 20 '18 at 17:30
Welcome to Stack Overflow! Next time, when adding a code snippet, highlight all of your code and press Ctrl + K on your keyboard to properly format it. Cheers!
– dwirony
Nov 20 '18 at 17:30
Welcome to Stack Overflow! Next time, when adding a code snippet, highlight all of your code and press Ctrl + K on your keyboard to properly format it. Cheers!
– dwirony
Nov 20 '18 at 17:30
add a comment |
1 Answer
1
active
oldest
votes
Initially I'd recommend an input box and check that the input is valid:
Dim myDate as String
myDate = InputBox("Please enter a date (dd/mm/yyyy)", "Date filter", Format(Now() - 7, "dd/mm/yyyy"))
If IsDate(myDate) Then
' Continue with logic
Else
MsgBox "Invalid date"
End If
Be warned that IsDate is a pretty flaky function, but you can go on to make this code fancier, if you see fit.
What is it that makesIsDate
flaky?
– Mathieu Guindon
Nov 20 '18 at 17:52
@NeepNeepNeep would this bypass the need for the UserForm completely? Or would this be the code tied to the UserForm?
– IREVEL
Nov 20 '18 at 18:06
@IREVEL typeInputBox "test"
+ ENTER in the immediate pane (Ctrl+G), you'll answer that question fast enough. (spoiler: the fully-qualified name isVBA.Interaction.InputBox
, i.e. same module as theMsgBox
function - yes, it replaces your userform entirely.... although a UserForm has other advantages, like, you could embed the validation and actively prevent the user from okaying the modal dialog with invalid input)
– Mathieu Guindon
Nov 20 '18 at 18:15
Thank you both for your help. I ended up incorporating the 'InputBox' before running any of the auto filtering/sorting. Had it populate into a specific cell in a hidden sheet, and then referenced that cell as the date to sort in the Main Sub. Worked wonderfully. Thanks again!
– IREVEL
Nov 20 '18 at 21:42
@MathieuGuindon IsDate is notoriously permissive and will allow pretty much any format that comes along, whatever your regional settings, i.e. "31/12/2018", "12/31/2018" and so on. That said, it is useful as a final arbiter for valid leap year dates
– NeepNeepNeep
Nov 21 '18 at 10:52
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398060%2frunning-autofilter-vba-macro-that-has-a-pop-up-to-enter-date%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Initially I'd recommend an input box and check that the input is valid:
Dim myDate as String
myDate = InputBox("Please enter a date (dd/mm/yyyy)", "Date filter", Format(Now() - 7, "dd/mm/yyyy"))
If IsDate(myDate) Then
' Continue with logic
Else
MsgBox "Invalid date"
End If
Be warned that IsDate is a pretty flaky function, but you can go on to make this code fancier, if you see fit.
What is it that makesIsDate
flaky?
– Mathieu Guindon
Nov 20 '18 at 17:52
@NeepNeepNeep would this bypass the need for the UserForm completely? Or would this be the code tied to the UserForm?
– IREVEL
Nov 20 '18 at 18:06
@IREVEL typeInputBox "test"
+ ENTER in the immediate pane (Ctrl+G), you'll answer that question fast enough. (spoiler: the fully-qualified name isVBA.Interaction.InputBox
, i.e. same module as theMsgBox
function - yes, it replaces your userform entirely.... although a UserForm has other advantages, like, you could embed the validation and actively prevent the user from okaying the modal dialog with invalid input)
– Mathieu Guindon
Nov 20 '18 at 18:15
Thank you both for your help. I ended up incorporating the 'InputBox' before running any of the auto filtering/sorting. Had it populate into a specific cell in a hidden sheet, and then referenced that cell as the date to sort in the Main Sub. Worked wonderfully. Thanks again!
– IREVEL
Nov 20 '18 at 21:42
@MathieuGuindon IsDate is notoriously permissive and will allow pretty much any format that comes along, whatever your regional settings, i.e. "31/12/2018", "12/31/2018" and so on. That said, it is useful as a final arbiter for valid leap year dates
– NeepNeepNeep
Nov 21 '18 at 10:52
|
show 1 more comment
Initially I'd recommend an input box and check that the input is valid:
Dim myDate as String
myDate = InputBox("Please enter a date (dd/mm/yyyy)", "Date filter", Format(Now() - 7, "dd/mm/yyyy"))
If IsDate(myDate) Then
' Continue with logic
Else
MsgBox "Invalid date"
End If
Be warned that IsDate is a pretty flaky function, but you can go on to make this code fancier, if you see fit.
What is it that makesIsDate
flaky?
– Mathieu Guindon
Nov 20 '18 at 17:52
@NeepNeepNeep would this bypass the need for the UserForm completely? Or would this be the code tied to the UserForm?
– IREVEL
Nov 20 '18 at 18:06
@IREVEL typeInputBox "test"
+ ENTER in the immediate pane (Ctrl+G), you'll answer that question fast enough. (spoiler: the fully-qualified name isVBA.Interaction.InputBox
, i.e. same module as theMsgBox
function - yes, it replaces your userform entirely.... although a UserForm has other advantages, like, you could embed the validation and actively prevent the user from okaying the modal dialog with invalid input)
– Mathieu Guindon
Nov 20 '18 at 18:15
Thank you both for your help. I ended up incorporating the 'InputBox' before running any of the auto filtering/sorting. Had it populate into a specific cell in a hidden sheet, and then referenced that cell as the date to sort in the Main Sub. Worked wonderfully. Thanks again!
– IREVEL
Nov 20 '18 at 21:42
@MathieuGuindon IsDate is notoriously permissive and will allow pretty much any format that comes along, whatever your regional settings, i.e. "31/12/2018", "12/31/2018" and so on. That said, it is useful as a final arbiter for valid leap year dates
– NeepNeepNeep
Nov 21 '18 at 10:52
|
show 1 more comment
Initially I'd recommend an input box and check that the input is valid:
Dim myDate as String
myDate = InputBox("Please enter a date (dd/mm/yyyy)", "Date filter", Format(Now() - 7, "dd/mm/yyyy"))
If IsDate(myDate) Then
' Continue with logic
Else
MsgBox "Invalid date"
End If
Be warned that IsDate is a pretty flaky function, but you can go on to make this code fancier, if you see fit.
Initially I'd recommend an input box and check that the input is valid:
Dim myDate as String
myDate = InputBox("Please enter a date (dd/mm/yyyy)", "Date filter", Format(Now() - 7, "dd/mm/yyyy"))
If IsDate(myDate) Then
' Continue with logic
Else
MsgBox "Invalid date"
End If
Be warned that IsDate is a pretty flaky function, but you can go on to make this code fancier, if you see fit.
answered Nov 20 '18 at 17:22


NeepNeepNeepNeepNeepNeep
67547
67547
What is it that makesIsDate
flaky?
– Mathieu Guindon
Nov 20 '18 at 17:52
@NeepNeepNeep would this bypass the need for the UserForm completely? Or would this be the code tied to the UserForm?
– IREVEL
Nov 20 '18 at 18:06
@IREVEL typeInputBox "test"
+ ENTER in the immediate pane (Ctrl+G), you'll answer that question fast enough. (spoiler: the fully-qualified name isVBA.Interaction.InputBox
, i.e. same module as theMsgBox
function - yes, it replaces your userform entirely.... although a UserForm has other advantages, like, you could embed the validation and actively prevent the user from okaying the modal dialog with invalid input)
– Mathieu Guindon
Nov 20 '18 at 18:15
Thank you both for your help. I ended up incorporating the 'InputBox' before running any of the auto filtering/sorting. Had it populate into a specific cell in a hidden sheet, and then referenced that cell as the date to sort in the Main Sub. Worked wonderfully. Thanks again!
– IREVEL
Nov 20 '18 at 21:42
@MathieuGuindon IsDate is notoriously permissive and will allow pretty much any format that comes along, whatever your regional settings, i.e. "31/12/2018", "12/31/2018" and so on. That said, it is useful as a final arbiter for valid leap year dates
– NeepNeepNeep
Nov 21 '18 at 10:52
|
show 1 more comment
What is it that makesIsDate
flaky?
– Mathieu Guindon
Nov 20 '18 at 17:52
@NeepNeepNeep would this bypass the need for the UserForm completely? Or would this be the code tied to the UserForm?
– IREVEL
Nov 20 '18 at 18:06
@IREVEL typeInputBox "test"
+ ENTER in the immediate pane (Ctrl+G), you'll answer that question fast enough. (spoiler: the fully-qualified name isVBA.Interaction.InputBox
, i.e. same module as theMsgBox
function - yes, it replaces your userform entirely.... although a UserForm has other advantages, like, you could embed the validation and actively prevent the user from okaying the modal dialog with invalid input)
– Mathieu Guindon
Nov 20 '18 at 18:15
Thank you both for your help. I ended up incorporating the 'InputBox' before running any of the auto filtering/sorting. Had it populate into a specific cell in a hidden sheet, and then referenced that cell as the date to sort in the Main Sub. Worked wonderfully. Thanks again!
– IREVEL
Nov 20 '18 at 21:42
@MathieuGuindon IsDate is notoriously permissive and will allow pretty much any format that comes along, whatever your regional settings, i.e. "31/12/2018", "12/31/2018" and so on. That said, it is useful as a final arbiter for valid leap year dates
– NeepNeepNeep
Nov 21 '18 at 10:52
What is it that makes
IsDate
flaky?– Mathieu Guindon
Nov 20 '18 at 17:52
What is it that makes
IsDate
flaky?– Mathieu Guindon
Nov 20 '18 at 17:52
@NeepNeepNeep would this bypass the need for the UserForm completely? Or would this be the code tied to the UserForm?
– IREVEL
Nov 20 '18 at 18:06
@NeepNeepNeep would this bypass the need for the UserForm completely? Or would this be the code tied to the UserForm?
– IREVEL
Nov 20 '18 at 18:06
@IREVEL type
InputBox "test"
+ ENTER in the immediate pane (Ctrl+G), you'll answer that question fast enough. (spoiler: the fully-qualified name is VBA.Interaction.InputBox
, i.e. same module as the MsgBox
function - yes, it replaces your userform entirely.... although a UserForm has other advantages, like, you could embed the validation and actively prevent the user from okaying the modal dialog with invalid input)– Mathieu Guindon
Nov 20 '18 at 18:15
@IREVEL type
InputBox "test"
+ ENTER in the immediate pane (Ctrl+G), you'll answer that question fast enough. (spoiler: the fully-qualified name is VBA.Interaction.InputBox
, i.e. same module as the MsgBox
function - yes, it replaces your userform entirely.... although a UserForm has other advantages, like, you could embed the validation and actively prevent the user from okaying the modal dialog with invalid input)– Mathieu Guindon
Nov 20 '18 at 18:15
Thank you both for your help. I ended up incorporating the 'InputBox' before running any of the auto filtering/sorting. Had it populate into a specific cell in a hidden sheet, and then referenced that cell as the date to sort in the Main Sub. Worked wonderfully. Thanks again!
– IREVEL
Nov 20 '18 at 21:42
Thank you both for your help. I ended up incorporating the 'InputBox' before running any of the auto filtering/sorting. Had it populate into a specific cell in a hidden sheet, and then referenced that cell as the date to sort in the Main Sub. Worked wonderfully. Thanks again!
– IREVEL
Nov 20 '18 at 21:42
@MathieuGuindon IsDate is notoriously permissive and will allow pretty much any format that comes along, whatever your regional settings, i.e. "31/12/2018", "12/31/2018" and so on. That said, it is useful as a final arbiter for valid leap year dates
– NeepNeepNeep
Nov 21 '18 at 10:52
@MathieuGuindon IsDate is notoriously permissive and will allow pretty much any format that comes along, whatever your regional settings, i.e. "31/12/2018", "12/31/2018" and so on. That said, it is useful as a final arbiter for valid leap year dates
– NeepNeepNeep
Nov 21 '18 at 10:52
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398060%2frunning-autofilter-vba-macro-that-has-a-pop-up-to-enter-date%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to Stack Overflow! Next time, when adding a code snippet, highlight all of your code and press Ctrl + K on your keyboard to properly format it. Cheers!
– dwirony
Nov 20 '18 at 17:30