Working with Arrays in Excel VBA VIDEO

Arrays are the selection of multiple columns and rows in Excel. In this video, we will learn how to manipulate an array with simple multiplication. Learning about this in isolation is not highly applicable. However, what is learned here is important for more practical actions when using VBA.

ad

Socialization Agents

Socialization is the process in which people learn how to be members of a specific society. Several institutions play a critical role in the socialization of people, and these are the family, religion, schools, peers, job, and government. We will look at each below.

Family

The family is perhaps the strongest socializing agent in a person’s life. The earliest knowledge about the world and how a child sees the world is shaped by the family initially. The family continues to influence the child throughout their lives by accepting or rejecting the child’s actions.

ad

Different families also socialize their children in different ways. For example, worker-class families often emphasize obedience while middle and upper-class families focus on creativity and critical thinking. As such, these children from these different families are taught that different things are important.

Religion

Religion plays a critical role in socializing people. Even in families that do not encourage religion, they send a message that religion is not important. Often religion provides various ceremonies that are connected with the family. Examples can include weddings, funerals, and rites of passages ceremonies like Bar mitzvahs among Jews.

Religion also often provides a moral framework for a person. People learn right from wrong by going to church or reading the religious text of their religion. REligions also define roles for people in society, such as the role of the man and woman in marriage and the local leadership.

School/Peers/Government

Outside the home, the place that may have the most influence on individuals and socialization may be the schools. Teachers serve as role models and surrogate parents through spending entire days with children. Students learn about the values of their society at school as well. Schools do not only teach subjects but also help to shape a student’s worldview.

One of the reasons for the huge debate over education in the US is what values should be taught in school. Many parents are pushing back against what schools want to do in the classroom because, fundamentally, the parents do not support the current form of socialization in schools today.

Peers are often met at school and also influence the socialization process. Peers teach people how to interact with members of their age group. Peers can be a positive or negative influence on socialization. However, at least among young people, friends are generally a negative influence. This leads to the point that the different agencies spoken of here often compete in terms of their influence over a person.

The government is also mentioned here because the government is often heavily influencing the school. Through policies government influences almost all aspects of a person’s life. Such things that are influenced by the government are schools, salaries, health, retirement, marriage, among other things.

Governments are also often involved in shaping the values of their citizens. This is done by encouraging patriotism and nativism. America is famous for supporting the American way and the American Dream among its people. In addition, democratic values are highly encouraged and even exported to other countries.

Job

When people grow up, the workplace can also serve a role in socialization. Most workplaces and companies have a set of values that they want their employees to accept and model. There are also unwritten rules of interaction, such as dealing with superiors and how to deal with peers.

People also frequently change jobs, which means they accept and reject various values they have throughout their lives. For example, something that is acceptable in one company may be unacceptable in another. Sometimes the only way to learn this is to gain the approval or disapproval of others in the company.

Media

Another powerful influence on socializing is media. People often decide what is right or wrong based on the media. Media has such influence on people’s lives now that there are accusations of “fake news” when views are shared that are not appreciated by one side or the other.

There is also the idea of “cancel culture,” which involves punishing someone by making them disappear from the internet for saying something that offends somebody. This is yet another example of socialization as it provides examples of things that should be said in the online context. This is even more amazing because people can be canceled for things they said before “cancel culture” even existed. In other words, a person needs to be perfect even before the standards change; otherwise, they will be held responsible for something they said even before saying such a thing was so offensive.

Conclusion

As long as people live among each other, socialization will be important. The examples provide here share a glimpse of the major agents in the socialization of people.

Creating Local Arrays in Excel VBA

Local arrays are arrays that are stored in Excel but are not necessarily seen in the worksheet. We will now look at two ways in which we can create local arrays in Excel using VBA. These two ways are

  • Hardcoded by the developer
  • Inputted by the user

Hardcoded

Below is an image of what we want to create.

The numbers in green are for labeling the rows and columns. What is really going into VBA is the numbers in black. For example row 1 column 1 contains the number 10, row 1 column 2 contains 12, etc. To do this we need to create a subroutine that makes an array. Below is the code

Option Base 1
Sub newArray()
Dim myArray(2,2) As Integer
myArray(1,1) = 1
myArray(1,2) = 2
myArray(2,1) = 3
myArray(2,2) = 4
MsgBox myArray(1,1)

Here is what we did

  1. Line 1 we set an option called Options Base 1. If we do not o this, VBA adds an extra column to the array called 0. THis is not wrong but can cause problem later if you are not aware this can happen.
  2. Line 2-3 we intitate the sub routine and Dim the array with a 2×2 strcuture
  3. Line 4-6 are used to set each cell in the array to a specific value.
  4. Line 7 outputs the value in Row 1 column 1 as proof the subroutie worked

Below is the output

The one in the message box is from row 1 column 1 of the array. The output below is from the locals window in the developer.

This image provides evidence that the array works. You can see that each position of the array has a stored value.

User Inputted Array

It is also possible for users to input values into an array. Doing this requires input boxes and the use of nested for loops, both of these were discussed in a prior post. Below is the code.

Option Base 1
Sub makeArray()
Dim myArray(2,2) As Integer
Dim i As Integer, j As Integer
For i = 1 To 2
	For j = 1 To 2
		myArray(i,j)=InputBox("Enter number for element " & i & "," & j)
		Next j
	next i
End Sub

The first 4 lines are the same as the last code. Line 5 is where the for loop begins. The purpose of the for loop is to go across each column then skip down to the next row. The input box asks the user for a number as shown below

If you put the same numbers into the input box as in the original array you will see the following in the locals window.

Conclusion

Local arrays can be useful when combined with other ideas in Excel VBA. This will be covered in a future post

Intro to Arrays in VBA

Arrays are simply the use of multiple rows and columns in Excel. Generally, this happens through selecting them. The benefit of arrays is that you can perform calculations on several rows and columns of data at once. Below is a picture of an array.

The Purpose

ad

Our purpose is going to be to take an array and multiple all the values by 3. In order to do this, we will have to use nested for loops and learn some terminology.

The for loops are difficult to master if you are new to coding. However, what we need is for VBA to loop through all the rows and loop through all the columns completing the calculation we want. This is commonly done by labeling the rows as the letter “i” in coding and columns as the letter “j”. Below is a picture of what I have just said.

For the actually coding here are the variables we need to declare in our subroutine

  • i for rows
  • j for columns
  • nr for number of rows
  • nc for number of columns

We need to count the rows and columns so the for loop knows when to stop.

Below are the functions we will use

  • A function that counts the rows
  • A function that counts the columns
  • A function that selects the cells
  • Multiply by 3 the selected cells

Below is the actual code

Sub timesThree()
Dim i As Integer, j As Integer, nr As Integer, nc As Integer
nr = Selection.Rows.Count
nc = Selection.Columns.Count
For i = 1 To nr
    For j = 1 To nc
    Selection.Cells(i, j) = Selection.Cells(i, j) * 3
    Next j
Next i
End Sub

Here is what the code does

  1. Line one gives the subroutine a name
  2. Line 2 declares the variables
  3. Line 3 and 4 tell VBA to count the number of rows and columns
  4. Line 5-10 is the for loop. i and j are set to 1 initially and continue until whatever value nr and nc have. Whatever position the selected cell is at is multplied by three.

Below is a picture of the before and after effects of using this code on an array.

In the picture above you can see the array is 3×3 and selected. The code is to the right. In the bottom right you have the locals window which will provide information on the variables that are created. Below is the output

Here you can see that all the values in the array have been multiplied by three as planned. The highlighted yellow in the code indicates that we are at the end of the code and are ending the subroutine. The information in the locals window is hard to read but simply shares information on the values in the various variables that were created.

Conclusion

With this information, it is possible to create arrays and manipulate them in Excel VBA. As already mentioned, this information must be used in combination with other techniques to truly be useful for the average developer.

Roles and Status in the Classroom

ROles and status are terms related to societies that can also be examined from the classroom perspective. This post will look at roles and status and how they influence the classroom learning environment.

Roles

Roles are behavior patterns that are associated with a person’s status. In the classroom, the most common roles are teacher and student. However, this is an overgeneralize as the roles of an individual could be nuanced and complicated by various factors. In addition, a student and or the teacher’s role in the classroom can be influenced by their roles outside the classroom, as we will see.

Status is a term related to a role and is the benefits and burdens of a person’s role. For example, there are advantages to being a teacher in the classroom. One is the leadership position in which the teacher tells students what to do instead of being told what to do. However, there are also burdens such as discipline problems, dealing with difficult parents, and low pay. There are also pros and cons to being a student. Students have much less responsibility compared to teachers but are also under constant surveillance and control by adults.

Being a teacher is an example of an achieved status or a form of status that a person works for. Other examples of achieved status are entrepreneurs, actors, athletes, pilots, etc. Ascribed status, on the other hand, is a status that a person does not choose. Generally, many K-12 students have this status ascribed to them by their parents and the government, and many would prefer not to be a student.

Teachers and students often have multiple roles, which is called a role set. A teacher could be a parent, spouse, family member, friend, leader, a musician in addition to their teaching role. A student can also have multiple roles such as child, sibling, athlete, worker, to name a few.

If a person has to perform too much under their role, it can lead to role strain. For example, teaching is often demanding enough for many individuals. If the job becomes too burdensome, burnout can take place. The same is true for students who are struggling with academics.

If two or more roles lead to conflict, this is an example of role conflict. For example, suppose a teacher is having problems in their role as a parent. In that case, it can carry over and affect their performance in the classroom. The same can also be said of a student whose role as a child can bring problems into the classroom.

All of the ideas mentioned here have ignored the classroom to a large extent. Students can have different roles within the classroom. Some are more of the leader type, others are the class clowns, while many are simply followers. Teachers can also have varying roles based in part on their teaching style. Some teachers are more controlling, while others are more hands-off. Status can also play a role. An older respected teacher has a different role in their classroom than an untested young teacher.

Conclusion

Roles and status are things people acquire and seek throughout their lives. Sometimes this is good, but not always. Students and teachers need to be aware of their roles so that they can understand when things may not be working well in the classroom.

For Next Loops in Excel VBA

For Next loops are a type of count controlled loop in VBA. By count controlled it is meant that this loop is performed a certain number of times as determine by the criteria set by the developer. In this post, we are going to learn how to use For Next loops with functions and with Subroutines.

For Next Explained

Below is a high level overview of the behavior of For Next loops in a visual.

The For Next loop begins at i. This is normally one but it is flexible. In addition, the value normally increases by 1 also. Next, we have the loop it repeats until i reaches whatever the limit is. Often the limit is set by the number of rows or some other means and is generally called n in coding. The limit continues based on an if then statement. If i is less than the limit then it will increase by one and repeat the process. If i is greater than the limit then it will exit.

ad

One thing that is missing from this diagram that is also important is some sort of way to count how many times the For Next loop finds what the developer is looking for. This value is often set to c and increase by one each time through the code. This will make more sense in an actual example.

Code for Function

Below is the code for a function that uses a For Next loop. This function will check if out number is divisible by 4 or 7.

Function numberCheck(n As Integer) As Integer
Dim i As Integer, c As Integer
For i = 1 To n
    If i Mod 4 = 0 Or i Mod 7 = 0 Then
    c = c + 1
    End If
Next i
numberCheck = c
End Function

In the code above we are doing the following.

  1. Creating a function called “numberCheck) that sets n as our variable for the limit
  2. We dim the c and c variables
  3. Next, is our loop, i is set to 1 and will continue until n which is picked by the developer
  4. After this, is our If Then statement. If our number from n is divisible by 4 or 7 then the c value will go up 1.
  5. Then we repeat this process until we reach the end of n
  6. Exit function.

The image below shows this function in action.

The function is counting how many numbers between 1 and 16 are divisible by 4 or 7. The answer is 6.

Subroutine Code

We will now complete a similiar task with a subroutine. This time we want to count a selection of rows and see how many number 3s it has. Below is the code.

Sub CountThrees()
Dim nr As Integer, i As Integer, c As Integer
nr = Selection.Rows.Count
For i = 1 To nr
If Selection.Cells(i, 1) = 3 Then c = c + 1
Next i
MsgBox ("There are " & c & " threes in your selection.")
End Sub

This code does the following

  1. We give the subroutine the name “CountThrees”
  2. We dim nr for the number of rows, and we also dim i and c as in the previous example
  3. The for next loop is next and goes from 1 to the end of all the rows
  4. Inside the for next loop the if then statement looks at the cells that are selected in the Excel spreadsheet and searches for those that are the number for. Then these 3 are counted and saved in the c function
  5. Then the process repeats it’s self
  6. At the end, a message bx appears telling the user how many threes are found

Below is an image of this codes actions

Here is the data the subroutine will analyze. You can count for yourself that there are three 3 in this column

Below is the result

The image below shows what is happening in VBA

The image above comes from the locals window in VBA. You can see at the end of the four loop that we ten rows of data (nr) i was set to 11, which is greater than nr which cause the loop to exit. Lastly, c was set to three which indicates that there were 3 threes in the selection

Conclusion

For Next loops are another useful tool for VBA developers. They allow you to let the context of the code determine how many iterations the loop completes.

close up of girl writing

Homeschooling’s Growth

Within the United States, there has been a growth in homeschooling over the past few years. According to the National Home Education Research Institute, homeschooling has gone from 5.4% to 11% of the population. In other words, the number of students studying at home has doubled.

It is not clear if this growth will continue or due to temporary problems. The purpose here is to explore several reasons parents are turning to homeschooling, given the challenges of teaching children.

Health and Lockdowns

For several years now, schools have essentially been out of business. Due to lockdowns and social distancing, it has not been possible in many places to even send one’s kids to school. Keeping a child at home temporarily can probably be worked out by many parents. However, when it is not clear when schools will reopen and or when schools open and then close and open again due to outbreaks and staffing shortages, it can become too unpredictable to consider being flexible.

ad

Such a situation has encouraged parents to keep their kids at home due to the instability of schools at the moment. There are no lockdowns or other health restrictions to impede the learning experience with homeschooling. Children often need consistency to learn, and for many, homeschooling provides a consistency that was unavailable for several years from public schools. Whether this continues or not remains to be seen.

Concerns with Values

Recently, there has been a large amount of dissatisfaction with the decisions school leaders have made regarding health, curriculum, race, and matters related to sexuality in schools. In several counties in various states, parents have been challenging these decisions made by school boards that affect their children. The fighting has been so bitter that parents have been arrested, school board members threatened, and there was even a call for parents to be labeled terrorists. Such accusations are unfortunate, but they also make it difficult to learn.

In response to this administrative chaos and a disagreement with the values schools are supporting now, parents are turning to homeschooling. By homeschooling, the parent becomes the leader of the child’s learning and no longer needs to fight with teachers and administrators about what is happening in the classroom. By keeping children at home, parents can be sure that the values they support, rather than the school’s values, are passed on to the children.

Unfortunately, schooling has come to this. However, the alternatives for many parents involve fighting with educational leaders who think they know better, moving to another school district, and or charter/private schools. Homeschooling is a tremendous opportunity for those who disdain confrontation and lack the resources for the other choices.

Other Students

Bullying and peer pressure have been problems in schools for a long time. Now, there are dangers of not just being picked on or pressures such as drugs but now extreme violence in school shootings. Many parents want their children to be in a safe a stable environment. If the home can provide this, it should not be surprising that parents turn to this form of education for their children.

Students need the kind of attention that homeschooling provides. This can help them grow as they imitate their parents or tutor. People often imitate the people they spend time with. If a child spends time with their parents, they will act like them. However, if a child spends time with friends, they will act like friends. Parents have to decide which influence is better for their own children.

Conclusion

Homeschooling may not be for everyone, but it is becoming clear to many the public schools cannot provide the stable, safe environment that parents want for their children. In addition, the desire to make students aware of every social injustice takes time away from learning how to do something about it, such as being a model and skilled worker who was educated to excel.

ElseIf Statements in Excel VBA VIDEO

ElesIf statements in VBA allow the developer to include multiple alternative actions within a subroutine or function. This allows for the code do execute goals that are more complex than just If-then statements. The video below addresses how to develop a function that includes Else-if statements.

Ad

Do Until Loops in Excel VBA

Do until Loops in VBA are for repeating a task until some criteria is met. How this is used can vary widely depending on what the developers goals are for implementing the loop in the first place. In this post, we will look at an example of the use of a general do loop. By general do loop we mean a loop that has no predetermine number of times it will run.

ad

Our goal is going to be to create a subroutine that ask the user for a number. This number will then be squared until it is greater than 2000. Once the number is larger than 2000, VBA will exit the loop and share the results with the user.

Below is a picture of how the Do loop is suppose to work.

As you can see the loop takes a number, squares it and then checks if the number is larger than 2000. If the number is larger than 2000 VBA exits the loop. If not, the new x value is the square of the old one and the process repeats.

Below is the code for completing this task in VBA

Sub squareLoop()
Dim x As Double, y As Double
x = InputBox("Enter your number")
Do
y=x*x
If y > 2000 Then Exit Do
x=y
Loop
MsgBox ("Your number is " & y)
End Sub

Here is what each line of code does.

  1. Line 1 declares the subroutine called “squareLoop”
  2. Line 2 we dim the two variables we need
  3. Line 3 is the code for creating the input box for the user and saves this information as our x variable
  4. Line 4 is the beginning of or do loop
  5. Line 5 is were we square our x variable and name it the y variable
  6. Next we have our if-then statement. If y is greater than 2000 than we exit the do loop
  7. In line 7 if our y value is not greater than 2000 than we save it as the new x value and return to the beginning of the loop in line 4-5
  8. Once we have a value greater than 2000 we skip to the bottom of the code and output a message box

The output is shown below

First Excel ask you for a number. For our example, we put the number 10.

Next, VBA squares the input number

10 * 10 is 100 which is not greater than 2000 so VBA goes through the loop again

The second time through are value is greater than 2000 so we get the message box with our value.

This is a relative simple process that has greater implications.

Conclusion

Do loops are another powerful tool you can implement in Excel VBA. The ability to automate repetitive task is valuable for saving time to deal with other matters.

Using Else-If Statements in Excel VBA

Else-If statements allow the developer to have their function or subroutine consider multiple alternatives. This can allow a piece of code to evaluate multiple criteria quickly. This will explain how to use Else-If statements in Excel VBA.

Ad

In this example, we are going to make a function that checks the score that student earned on a English proficiency exam and then assigns a string indicating what level the student is at. Below is a picture of the Excel worksheet before we create the function.

We want to fill the “Level” column automatically. Below is a partial visual of what the code will do.

We want Excel VBA to check the score and assigned a level based on the score. For example, if the student score 9 or higher than Excel VBA will assign a level of “Expert” to the student. If the students score 8 or higher but less than 9 than the student will be assigned the level of “Very good.” This continues until the score of 1 which is not seen in the graphic above.

The code below is the actual code that is placed in the VBA developer.

Function level(score As Double) As String
If score >= 9 Then
    level = "Expert"
ElseIf score >= 8 Then
   level = "Very good"
ElseIf score >= 7 Then
    level = "Good"
ElseIf score >= 6 Then
    level = "Competent"
ElseIf score >= 5 Then
    level = "Modest"
ElseIf score >= 4 Then
    level = "Limited"
ElseIf score >= 3 Then
    level = "Extremely limited"
ElseIf score >= 2 Then
    level = "Intermittent"
ElseIf score >= 1 Then
    level = "Nonuser"
End If
End Function

At the top of the code, we declare a function and give it the name “level”. This function takes one argument called “score” the input into the function is a numerical value but the output is a string. After this, we have are first ElseIf statement where VBA checks if the score is 9 or higher. If the score is then the level is set to expert. This process continues until the number 1. After this the If statement ends and the function ends.

Below is the output of the code found above

It appears everything is working.

Conclusion

This example shared one way to employ else-if statements in Excel VBA. With a basic example such as this it is possible to employ else-if statements in ways that are much more complex.

city group people police

Classroom Management and Theories on Deviance

Deviance is something teachers and administrators deal with every day when managing students. Deviance is simply a fancy word for the breaking of social norms and rules. In other words, in the context of classroom management, deviance is the everyday misbehavior of students.

There are two types of deviance. Primary deviance is misbehavior that does not have a long-term effect in terms of the perception or reputation of the person. For example, a student talking out of turn may be primary deviance if it is not too common. Secondary deviance is misbehavior that can give a student a label that strongly harms how others perceive him. For example, getting into fights, drug use, and academic dishonesty often give a student a poor reputation that is hard to overcome. When this happens, the student’s status is linked to deviant behavior.

Fighting Deviance

Schools work to maintain social control of their campus by enforcing rules and norms. Doing this helps to maintain the social order and stability of the organization. Common tools used to achieve this include the use of sanctions, both positive and negative.

ad

Positive sanctions are rewards; those familiar with behaviorism may be more familiar with positive/negative reinforcement. Negative sanction is the giving of consequences in behaviorism. Another term for this is positive/negative punishment. Another type of sanction is a formal sanction which is an official way of giving rewards or punishments. For example, citizenship awards might be a formal positive sanction, while suspension would be a formal negative sanction.

Theories of Deviance

Theories are several theories that attempt to explain deviance. Strain theory states that having a way to achieve a goal influences deviance. For example, no money for college may turn a student towards a life of crime as they see no other options. However, this is not the only potential response. Students may confirm and set aside their goal until an opportunity arises, if ever. Students may innovate, such as our example of turning to a life of crime. Students may lower their goal to achieve whatever they can, such as finishing high school and learning a trade. Students may also simply give up. Lastly, students may rebel with a desire to tear down the system. This last action partially explains the protesting in many places.

Strain theory does not have to deal with weighty issues such as going to college. Students can simply deviate because they are not allowed to go outside and play. As such, a teacher can anticipate certain behaviors from students through being familiar with strain theory.

Cultural deviance theory states that students may deviate if they conform to lower-class society norms. This implies a difference in class being a primary means of deviance. For example, students who grow up in gang culture will probably learn behaviors that are considered deviant by middle-class teachers. This will lead to problems in the classroom.

Cultural deviance theory is supported by at least two other theories. Differential association theory states that students learn deviant behaviors from others, and labeling theory states that those with power (teachers) determine acceptable behavior. Gang culture is considered deviant by most teachers, but whether this is considered deviant by gang members?

Lastly, control theory states that the strength of social bonds influences a student’s desire to perform deviant behaviors. In other words, students do not like to submit to strangers but will respond to people they know and respect.

Control theory proposes several ways to curtail deviant behavior. Attachment, if students are close to you, they will not want to deviate. Commitment, if you as the teacher are invested in the students, they will not want to deviate. Involvement, if you participate in activities with the students, they will not want to deviate. Belief, if students agree with what you want or think, they will not want to deviate.

Conclusion

Deviance is to be expected. Students want to push the limits, and it is the teacher’s job to deal with this. However, students need to learn from their mistakes so that their deviance does not become a major problem for them or the learning experience of others.

DISTINCT, GROUP BY, HAVING in SQL VIDEO

In this video, we will look at more commands that are used for aggregation in SQL. The three commands we will look at include the DISTINCT, GROUP BY, and the HAVING command. The DISTINCT command pulls unique values, the GROUP BY command allows you to aggregate data by categories, and the HAVING command allows you to filter results as you decide.

Errors & Subroutines in Excel VBA

Whenever you create a line of code you have to be aware of the potential of errors frustrating the end user of your product. This post will provide some guidance on how to deal with errors when developing subroutines for Excel VBA.

The Product

Our subroutine is a currency convertor. It specifically converts Thai Baht to US Dollars. Below is the code.

Here is what this code does.

  1. Line 1 declares sub along with its name
  2. Line 2 Declare variable we will need
  3. Line 3 will cause a box to appear that will ask the user to input the amount of Baht to convert
  4. Line 4 indicates the formula for conversion and the output

It is possible to run this code for the developer. However, this is not for a developer but for a user who may not be familiar with VBA coding. Therefore, we need to have a way to run this subroutine from the Excel spreadsheet.

To run this subroutine from the Worksheet we will create a button. This can be done by clicking

developers-> Insert->Button

Once the button is create Excel will ask you which macro to assign to it. Simply click on the macro that has the same name as the subroutine as shown below.

Implementation

If the user inputs numbers and presses okay the subroutine works fine as you can see below.

Here is the answer below

The Problem

However there are problems if we enter text into our input box or if we click cancel. In either case. We get the following.

Excel takes us to the VBA developer and shows an error message. This can be a serious problem if we want other people to use this subroutine. In order to fix this we will add a few lines to our code as shown below.

Here are the additions

  1. Line 3 as some code that says “On Error GoTo Here” this tells VBA that when there is any error to jump down to line 7 where the word “Here:” is
  2. Line 8 is executed whenever there is an error and this brings up the box “There was an error”
  3. Line 6 makes sure that the error box only occurs when there is an error. If you do not put this Exit Sub code in there the error box will appear every time you run the code whether there is an error or not.

Below is what happens now when there is an error.

Now when there is a problem this is what the end user will see. It’s not clear what the error is but this is less confusing then allowing them to see code and the developer application.

Conclusion

This post provided an example of how to deal with errors when working wit VBA. There is naturally more than one way to handle the problems presented here. However, this is one viable way.

green trees between white concrete buildings

Organization, Bureaucracies, & Schools

A school is a type of formal organization. An organization is a group of people who are working together as a body to do something. A formal organization is an organization that has rules and regulations. Another trait of many organizations is that they often have traits of bureaucracies. This post will explore different types of organizations and also explain the characteristics of bureaucracies.

Organization Types

There are several types of organizations. A voluntary organization is an organization that is based on a common interest. Many of the clubs that one would find in a school would qualify as a voluntary organization. Examples would include student council, art club, photo club, or drama club. These are generally voluntary in that students can choose or not choose to participate, and they often involve hobbies students enjoy. For teachers, voluntary organizations might include associations such as the National Education Association (NEA) or Kappa Delta Pi. Teachers are often the leaders of various after-school clubs and thus members of these organizations at the local school level.

ad

Coercive organizations, as the name implies, are organizations people are compelled to join. School is a coercive organization for many students as many young people do not want to be there. Another example is a prison, as most inmates do not want to be inmates. This leads to the point that different people have different views of organizations. A teacher will probably not think of their school as a coercive organization, but a student might.

Total institutions are organizations that have sweeping powers over the lifestyles and choices of the members. Prison is one such example. In addition, many cults can have a large influence over the lives of their members in a way that is totalitarian. With time, schools have been given more and more responsibility for students’ lives to appear as total institutions. Schools’ responsibilities now include transportation, breakfast, after-school programs, sports, sex education, supporting students with disabilities, second language instruction, etc. Some of these examples are so old that they seem comical. However, there was a time when schools did not do these things.

Lastly, a utilitarian organization is an organization people join for a reward such as a salary or prestige. For example, teachers may see the school at which they work as a utilitarian organization because of the money. A student who goes to college may see the college as a utilitarian organization because of the reward of a degree at the end of their studies. Again, how a person views an organization can vary as one voluntary organization is another person’s utilitarian organization

Bureaucracies

Organizations often become bureaucracies which are simple, highly formal organizations. It is difficult to tell when an organization is a bureaucracy. However, organizations exhibit several traits of bureaucracies when they reach this stage of development, and they are…

  • Strong hierarchy
  • clear division of labor
  • explicit rules
  • impersonal
  • meritocracies

Burecraies have a strong hiearchy. At schools, it is clear who is in charge. Often, you will see a picture of the principal somewhere and the rest of the administrative team. At the university level, you will have a president, VPs, Deans, Chairs, etc., clearly mapped out for everyone. There are also clear lines of labor. Teachers teach while administrators deal with administration only at smaller organizations do these lines blend. When an organization is larger enough, clearly delineating these things is critical to order.

Bureaucracies also have clear, explicit rules. Again, we all know how obsessed schools are with rules. There are rules for the cafeteria, the library, the classroom, the playground; there are general school rules. Then there are policies for teachers, parents, administrators, and the list goes on and on. The large number of policies and rules are overwhelming, especially if one moves to the district or state level.

Bureaucracies are also highly impersonal. For schools, this applies if the school is really big, perhaps several thousand students. Universities are often viewed as impersonal monsters where nobody cares, and they are often personified when people or students want to complain about them. A common name is “the system,” as in “the the system fail such and such.” Another term common today is “systemic racism”; however, systems are not alive and thus cannot actually be racists. People can be racist through the rules they implement and enforce within the system, but the system has no life or conscience of its own.

Lastly, bureaucracies are based on merit. Within the government, promotion is generally based on years of service and some sort of assessment. To become a teacher, a person has to receive a certain amount of training. To become an administrator, the same idea applies. Honor students earned good grades, which is the way they are being honored. The point is that in bureaucracies, merit is a common trait.

Conclusion

Organizations are a necessary part of the human experience. Everyone belongs to one organization or another for whatever reason. With time, organizations can grow and become bureaucracies that have their own pros and cons.

GROUP BY, DISTINCT, HAVING Commands in SQL

This post will focus on several SQL commands that are often used for aggregation purposes. These commands are

  • DISTINCT
  • GROUP BY
  • HAVING

The data that will be used as examples is the Seasons_Stats data from Kaggle which is a database of NBA statistics.

DISTINCT

The DISTINCT command allows you to find unique items in a column. As an example, we want to find all of the unique positions in our database. Below is the code and output to do this.

SELECT DISTINCT Pos
from Seasons_Stats

In this dataset we can see that there are more than 5 positions in basketball because some of the players were coded as playing more than one position

GROUP BY

The GROUP BY command allows use to aggregate data by a group or a category in a categorical variable. In the example below we sum the points scored by position and we sort them by descending order. The code and output is below.

SELECT SUM(PTS), Pos
from Seasons_Stats
Group BY Pos
Order by SUM(PTS) DESC

We can see that shooting guards are the most prolific scorers followed by small forwards. By aggregating the points and then grouping them by position we are able to achieve a more nuance insight into our data.

HAVING

The HAVING command is a filter command similar to the WHERE command but the HAIVNG command is used in the context of aggregation. In the example below, we want to filter our previous code so that we only see positions that scored more than 2 million points. If we use a WHERE command we will get an error message as shown below.

SELECT SUM(PTS), Pos
from Seasons_Stats
WHERE SUM(PTS) >= 2000000
Group BY Pos
Order by SUM(PTS) DESC

The WHERE command cannot deal with aggregate data. Below is the same code but with the using of the HAVING command.

SELECT SUM(PTS), Pos
FROM Seasons_Stats
GROUP BY Pos
HAVING SUM(PTS) >= 2000000
ORDER BY SUM(PTS) DESC

By adding the HAVING command and stating we only wanted positions that scored more than 2 million points everything now works.

Conclusion

Hopefully, after learning about this commands, aggregating data is a little easier in SQL. There is always more than one way to do anything when using code. However, at least one way has been explained to deal with the problems that were addressed here.

Borrowing Functions in EXCEL VIDEO

Borrowing functions is a great shortcut when making your own functions in VBA. Why reinvent something if it is already available? If the function is there this reduces the likelihood of introducing bugs and errors to your code if you try to make the function yourself. Using functions inside your own functions. The video found below explains how to use Excel functions in your own VBA developed functions.

Making If-Then Statements in Excel VBA

If-then statements are used in programming to allow a computer to execute an action based on a criterion. When this is done well, a program can do almost anything the developer wants. This post will provide an example of how to use if-then statements in Excel VBA.

Our goal is to create a subroutine in Excel VBA that determines if a number is divisible by five. In order to do this we have to do the following

  1. Create a variable to store input from the user
  2. Ask the user for a number
  3. Test if this number is divisible by 5
  4. If the answer is yes do one thing
  5. If the answer is no do something else
  6. exit the subroutine.

Below is a visual of what is described above

The Code

Below is the code for completing this task. There is no other way but to share the whole thing and then go through screenshots of each step.

Below is an explanation

The subroutine is called “divideByFive.” After this, we create a variable called x as an integer.

After creating the x variable, Excel will ask the user for a number in the input box as shown below. For this example, we inputted the number 25.

Once you input a number and press Enter and Excel will use the mod function to determine if the number is divisible by five. If the mod is zero this means there is no remainder and this triggers true for the if-then statement. Since our number is divisible by five, you will see the following which is the first message box.

If you put any number that is not divisible by 5 you will see the following, which is the second message box.

For simplicity, we skipped many steps, for example, if you type in text or press the cancel button you will get an error message.

Conclusion

If then statements can be used in your programming to achieve specific actions in your code. The example provided here is one simple way of doing this in Excel VBA

Making Subroutines in Excel VIDEO

Subroutines are another tool that can be developed in VBA. They are similar to functions but generally serve a different purpose. In particular, subroutines allow you to program in a modular manner in which different pieces of code are developed separately. In the video found here is an introduction to Creating a subroutine in Excel.

Naming Cells & Cell Ranges in Excel

Naming cells and ranges is a way to complete task in Excel. This post will explain how to use this tool.

The main benefit of naming cells and ranges in Excel may be that it simplifies completing operations inside Excel. In the example below you are going to see two numbers

If we ever want to use the values 10 and 5 we have to continue typing 10 and 5. By naming these cells we can you the text terms length and width instead. In the screenshot below you can see in the upper left corner how I rename the value 10 with the term “length.” To the left of the formula bar and directly below the clipboard is a box called the “name box.” Right now it says “C2” but we will change that.

In the picture below we have changed the label “C2” to the word “length.”

We also renamed cell “C3” to “width”. In the screens below we will now call the names of the cells rather than their numerical values and still complete calculations.

You can see how the cells are highlighted when their names are called. Below is the output when pressing enter.

Look closely at the formula bar. The values 10 and 5 are not there. Rather the formula bar shows = length * width. In other words, naming a cell or cells is similar to declaring a variable in a programming language.

You don’t have to name each cell individually. By highlighting the column with the names and the columns with the numerical values you can do this all with a few clicks in Excel. In the picture below I have “base” and “height” in one column and in the column right next to it I have the values of 5 and 4. If I highlight the 2 rows and 2 columns I can then name a cell range from the current selection. This can be done two ways

  1. Click formulas->Create from selection
  2. Shift + ctrl + F3

When you do this you will see the following

Excel has already determine where the names for each named cell is. Once you click okay you will have two new named cells, “base” set to a value of 5 and “height set to a value of 4.

Editing the Names

If you ever want to edit or delete the names you have given a cell all you have to do is click on formula->Name manager or you can also press ctrl + F3 and you will see the following

In this box you can create new cell names, delete cell names, or edit.

Creating Named Ranges

A named range is more than one cell that has a shared name. To do this you highlight the multiple rows and columns you want and follow the same steps as naming an individual cell. Below is a picture of this. Notice how in the name box the rage is given the name “data.”

Naming a range will allow you to type its name somewhere else and instantly reproduce all of the data.

Conclusion

Naming cells and ranges is a convenient way to access information in your worksheets inside Excel. When it is necessary to deal with complex operations this can be another tool that can be employed to do things quickly.

Society Types

Throughout human history, there have been various types of societies that people have been found to inhabit. Although it might not be totally fair or accurate to state that these societies have appeared in chronological order since most of these societies are still present today, the types that are considered “older” are not as frequently found as later forms of societies.

This post will cover several commonly found societies in the world. These types of societies are…

  • Hunter gather
  • Pastoral
  • Horticultural
  • Agricultural
  • Feudal
  • Industrial
  • Informational

Preindustrial Societies

The first four societies (Hunter-Gatherer, Pastoral, Horticultural, and Agricultural) are considered preindustrial societies.

Hunter-Gatherer

A Hunter-gather society focuses on hunting and foraging or gathering plants for food that are uncultivated. Family and tribe and generally important in these types of societies. Often, this society is migratory follow the resources they hunt or leaving an area once the resources are depleted.

Ad

Hunter-gatherers are considered the oldest type of society. However, today they are rare to find, except for indigenous peoples in various parts of the world. As the world becomes more urbanized and centralized, many governments prefer to keep a closer eye on people who wander from place to place and thus often discourage this lifestyle. As such, hunter-gathers are continuing to decline in terms of their numbers.

Pastoral

A pastoral society is a society in which the people have chosen to domesticate animals and plants. Despite this development, pastoral societies still had a nomadic lifestyle because they had to follow the food source of their animals. With the domestication of animals also came the use of the animals not just for food but also for clothing, transportation, and a general surplus of food. With this surplus, people began to specialize in various occupations needed by their society.

Horticultural and Agricultural

Horticultural societies developed in places with enough rain to allow people to stay in one place and grow feed in permanent settlements. Unlike the other two societies mentioned, horticulturalists did not live a nomadic lifestyle. What horticultural societies were missing was strong, reliable tools, which came with the development of agricultural societies.

Agricultural societies involved the use of tools that took farming from subsistence to a commercial level. People could not farm not just for survival but for profit. Various techniques for farming also developed, such as the use of fertilizers, crop rotation, and tools were use to boost yields. Specialization was also stronger, and many people would work in various occupations that had nothing to do with farming. Examples include the scholar, blacksmith, merchant, and more. With these various classes came division as one class or the other was viewed as superior to another.

Federal

Feudal societies are commonly found in the Middle Ages in Europe and in places such as Russia, Japan, and Thailand, among other places. This society did not involve a major technological change in how food production took place but was rather a time of power consolidation.

In any society, people begin to figure out how to exploit the rules to their advantage or to simply break the rules. Feudalism was essentially a rich gentry at the top exploiting the poor under them. All the poor seemed to get was protection from other rich people who wanted to conquer their village and become their slaves. There was no social mobility, and it was no way to break away and become independent.

Industrial Societies

The birth of industrial societies involves developing many forms of machinery that automate or speed up tasks. For example, steam-powered helped with transportation (trains and boats) and farm production (cotton). The improvements in technology led to increased factory production and allowed average people to own what used to be considered luxury items. Items such as paper and glass were quickly being made available for everybody.

It was during this time that people took their focuses away from the family to economic activity. A new generation of capitalists was able to unseat the feudalists from their seats of power. Essentially, capitalists were people who knew how to exploit and break the new rules for wealth and power.

Post-Industrial Societies

Perhaps the latest form of society is the post-industrial society, also known as the information age. Now, instead of making food (preindustrial focus) or making things (industrial focus), the information society uses various technical skills related to dealing with data. Today, there are jobs such as data scientists, analysis, computer science, etc., that focus on dealing with information in one way or another.

Work and career are also becoming much more important. A feudal farmer was not worried about a career, only surviving the day and relaxing in the even. The farmer’s life was focused on his family and not climbing the corporate ladder. Now, people are often socialized to put job and career before most other matters, which has weakened family relations.

Conclusion

Today people live in all of the societies mentioned here. It’s up to the person to decide which one of these societies works best for them. The primary goal was to share the various types of society found in the world today.

SQL and CASE WHEN Statements

Ads

CASE WHEN statements are the SQL version of If-Then statements. Essentially, SQL will perform certain behaviors based on the the criteria you set at the data analyst. In this post, we will go through several examples of the use of CASE WHEN statements using the NBA_salary database that is available on Kaggle.

Example 1

In the first example, we are going to use a CASE WHEN statement to identify if a basketball player is a shooting guard or not below is the code followed by the output.

SELECT Pos,Tm,
CASE WHEN Pos = 'SG' THEN 'Yes' END AS Shooting_Guard
FROM Seasons_Stats

In line one we SELECT two columns which are Pos and Tm. In the second line is the CASE WHEN statement. We are telling SQL that when Pos = ‘SG’ then place a yes in a new column called Shooting_Guard. You can see in the second row that there is a shooting guard there and this is why there is a yes. All the other rows have a NULL there. In the next example we will learn how to deal with the NULL values.

Example 2

In the second example we will replace the NULL values with the word No. Below is the code and output

SELECT Pos,Tm,
CASE WHEN Pos = 'SG' THEN 'Yes'ELSE 'No' END AS Shooting_Guard
FROM Seasons_Stats

The only change to the code is found in the second line. We added the ELSE command and place the word No in single quotes. This tells SQL that if a player is not a shooting guard then put the word No in the new column.

Example 3

In this example we are going to employ an OR command. As with If-Then statements, CASE WHEN Statements can use AND, OR, IN commands as well. Below we are going to have SQL say yes if a player is a shooting guard or a member of the CHS team.

SELECT Pos,Tm,
CASE WHEN Pos = 'SG' OR Tm = 'CHS' THEN 'Yes'ELSE 'No' END AS Shooting_Guard
FROM Seasons_Stats

The only change is found in line 2 again. We added the OR command and told SQL to say yes if Tm = CHS. This why if you look at the results we have a yes in row 3. Even though this player is a SF SQL still marked yes because he was on the CHS team.

Example 4

In our last example, we are going to make several categories by using several WHEN statements. Specifically, we are going to divide players based on how many points they scored. Below is the code and output.

SELECT PTS, 
CASE WHEN PTS > 2500 THEN 'Over 2500'
	WHEN PTS > 1500 AND PTS < 2499 THEN 'Over 1500'
	WHEN PTS > 500 AND PTS < 1499 THEN 'Over 500'
	ELSE 'Less than 500' END AS Pts_groups
FROM Seasons_Stats 

Here is an explanation

  1. We call the PTS column
  2. We create our CASE WHEN statements
    • If a player scored more than 2500 then say ‘Over 2500’
    • If a player scored more than 1500 and less then 2499 the say ‘Over 1500’
    • If a player scored more than 500 and less then 1499 the say ‘Over 500’
    • If a player scored less than 1500 then say ‘Less than 500’

Conclusion

This was just several simple examples of the use of CASE WHEN statements. The purpose of this command is to perform certain actions when certain criteria are set. When this happens powerful things can be done in SQL.

Creating a Subroutine in Excel VBA

Subroutine are another tool that can be used in Excel VBA for achieving the goals of the creator. Subroutine come from the idea of modular programming in which code that is reused multiple times is created and store in its own separate space and called whenever it is needed. By creating a subroutine separately it does not have to b recreated every time the functions it does are needed.

Many wonder what the difference is between a subroutine and a function. For generally readers this is actually highly esoteric but the main difference is that subroutines do not return a value while functions do. In addition, functions can be used in formulas but subroutines cannot. Right now this difference between functions and subroutines is not important but when programming becomes more complex this difference can be significant.

In the subroutine in this post we are going to make subroutine that calculates the area of a triangle. IN order to achieve this we need the subroutine to do following.

  1. Ask for the length of the triangle
  2. Ask for the width of the triangle
  3. Calculate the area
  4. Return the answer to the user

The code for this is not as complicated as it seems below is the code.

  1. In the first line we declare a subroutine use the Sub followed by the name of the subroutine.
  2. Line 2-3 is where we declare the two variables we will need. Input boxes appear to get this information
  3. Line 4 we calculate the area
  4. Line 5 we print the results of area in a message box

To run this subroutine you can press F5 while in the VBA developer. Once this is done you will see the following

First, Excel asks for the length of your triangle. BElow you can see I typed the number 10.

Next, Excel will ask you for the width of your triangle. I put 4

Finally, we get an answer of 20 which is the area of a triangle in this situation.

Conclusion

With a few lines of code we are able to have Excel calculate the area of a triangle. This could have been done with a function or directly on the worksheet. However, if there is a reason you do not want the user to interact with the worksheet or you need to repeat this calculation over and over a subroutine may be more appropriate.

Terms Related to Culture

Culture is a term that is often thrown around but totally understood. This post will define what culture is along with definitions of other terms related to it.

Culture

Culture is the beliefs, values, and practices people learn in a specific context or society. A society is a group of people who hold to a similar culture. From this definition alone, we need to understand what beliefs and values are and, naturally, terms related to these.

Values are the standard for what is good in a culture. The idea of good is related to axiology in philosophy. The ideal culture is how people ought to behave, while the real culture is how people actually behave. For example, ideally, a child will not talk back to their teacher, but the reality is different. It is important to understand the difference between ideal and real culture because people are unaware of this distinction.

Beliefs are ideas that a group of people holds to be true and relate to epistemology. For example, different cultures have different views on religion, the role of women, and or communication. Whatever they believe is essentially a truth to them, even if this is not the best assumption.

Norms are another term related to culture, and these are the proper behaviors in a culture. These norms can be formal and informal. Mores are norms related to moral behaviors such as lying. It is okay in many cultures to lie in specific circumstances. Folkways are norms that are missing this moral component. An example of a folkway would be a handshake. Shaking hands has nothing to do with right or wrong but Is an expected custom in the West.

When people violate these values, beliefs, norms, etc., social controls are implemented. Social controls are ways employed to force people to comply with the local culture.

Types of Cultures

There are also different types of cultures. High culture is the culture of the elite or royalty. They usually have a distinct way of behaving. Popular culture is the culture of the masses. A subculture is a culture within a culture such as any migrant community in the West.

Counterculture is a subset of the majority culture that rejects the beliefs and values of the majority culture. Essentially, when a group of people is numerous enough to reject the mores of the majority, there is potential for a subculture.

Problems with Culture

There are problems with culture, but they are normally associated with people’s perception of culture rather than with the culture itself. FOr example, ethnocentrism is the belief that one’s own culture is superior to others. IT is generally assumed that ethnocentrism is bad. However, this is generally coming from a perspective of cultural relativism, which states that a culture should be judged by its standards and no one else’s. Whether this is right or wrong depends on who you ask.

When ethnocentrism becomes extreme, it can lead to cultural imperialism, which is imposing one’s culture on someone else. The best example of this is looking at any colonial period and or empire that conquered another people. A group with more power thinks their way is better and looks to force this on the people they defeated.

However, when cultural relativism goes to an extreme, it leads to xenocentrism, which is the belief that another person’s culture is superior to one’s own. Again, what a person believes is their own business, but these are terms that people should be aware of when looking at culture.

Conclusion

All cultures are different and how people view them is different as well. The approach a person takes to a culture depends varies based on the culture they come from. Whether a culture is good or bad, right or wrong, is ultimately left to the individual to decide.

Aggregating Data in SQL

Aggregation is focused on summarizing data in order to develop some insights for taking action. This post will provide some simple ways to aggregate data in SQL. Specifically, we will learn how to use the following commands

  • COUNT
  • SUM
  • MIN
  • MAX
  • AVG

The data we are using is nba_salary which is available at the Kaggle website.

COUNT

The COUNT command allows you to count the number of rows that contain data in a table. In the code below we are going to count the number of data containing rows in the Seasons_Stats table.

SELECT COUNT(*)
FROM Seasons_Stats

As you can see the output is not much only one cell. In this first example we took into consideration all of the columns in the table. That is why there is an asterisk inside the COUNT function parentheses. However, you can also limit this to one or more columns as shown below.

SELECT COUNT(Player)
FROM Seasons_Stats

In the code above, we limited are query to only the “Player” column in the Table. You can see there is a differece in the count for this example and the previuous one. This indicates that some of the rows do not have data for the Player’s name.

SUM

The sum gives a total for numerical values. For our example, we are going to add up all the points scored by the players in our table.

SELECT SUM(PTS)
FROM Seasons_Stats

In this table, you can see the number of points scored. This command is rather straightforward in how to use it,

MIN and MAX

The MIN and MAX commands do what they say. To make this a little more interesting we are going to use these two commands together to find the range of the data. In the table we are going to use the Age column which shares the age of the player. We are going to do three things in the code below

  • calculate the minimum age
  • Calculate the maximum age
  • Find the difference between the MAX and the MIN to get the range of the age

The code and output are below

SELECT MIN(Age),
	   MAX(Age),
	   MAX(Age) - MIN(Age)
FROM Seasons_Stats

AVG

The AVG command calculates the average. this is also rather simple. Therefore, the code is below for the average age of a basketball player.

SELECT AVG(Age)
FROM Seasons_Stats

Conclusion

This post share some simple ways in which aggregation can happening when using SQL. There are naturally other ways that these tools can be used. However, for informative purposes this will provide a foundation for someone who is new to using SQL.

Making Dashboards in Excel VIDEO

Understanding how to make dashboards is an in demand skill. Many analyst jobs come with the expectation that the applicant can do this. Dashboards provide a way for a manager to play with different visualizations and or aggregations of some data without have to code or create anything themselves. In the video below, we will learn how to make a dashboard in Excel.

Borrow a Function in Excel

When creating a function of your own in Excel often it is more practical to borrow formulas rather than code all of this behavior yourself. In this post, we will learn how to create functions that borrow other functions already available in Excel. Specifically, we are going to create a function that calculates the range of a dataset through using the difference between the max and min functions of excel.

In the piture below we want to find the range of this data.

To get the answer we need to go into the VBA editor. This is available by clicking on the developer tab and clicking on Visual basic. When you do this you will see the following.

Once inside visual basic click on insert->module to add a new module. Inside this module is where we will place our code.

The Code

The code is rather simply and is shown below

At the top we type the name function to indicate to Excel what we are making. Next to this, we define the name of the function and inside the parentheses we indicate what the arguments are. after this we indicate the data type. In this situation the name of the function is “spread” and it takes the argument “spr” and the data type is “Double.”

In the next link we explain the behavior of the function. We use the command application.WorksheetFunction,Max() to call the max function whic will find the largest value in the spr data object. We repeat this process with the min function after the minus sign. Lastly, we end the function.

The Results

We can now test the function. In the first picture we call the function and in the second we show the results.

Now for the results

The dataset is small enough that you can check this manually. The number 12 is the largest while the number 1 is the smallest. The difference between 12 and 1 is 11.

Conclusion

With a few lines of code we can quickly borrow functions in Excel to create our own functions. Doing this can save a lot of time especially when you begin to create much more complex functions

Pivot Tables in Excel VIDEO

Pivot tables is one way of performing data aggregation in Excel. With a few clicks of the mouse many different insights can be extracted from some data. The video below explains how to make pivot tables in Excel. Knowledge of this is an expectation in many analyst jobs. Please like and comment on this video and let us know how we can continue to improve.

Data Validation in Excel VIDEO

Data-validation is a tool in Excel that is a great way to avoid making mistakes when inputting data. Anybody who has ever done any data collection knows the headache of have to fix data entry errors. These mistakes can have a sever impact on the analysis and conclusions that analyst makes. The video below demonstrates how to implement data validation in Excel.

Text Manipulation in Excel VIDEO

Text manipulation is becoming more and more important as unstructured data becomes more popular for analysis. Although Excel is not designed for serious text analysis there are some basics functions in Excel that can manipulate text for additional analysis. The video below address Basics of manipulating text in Excel

Acquired Characteristics & Natural Selection

Acquired characteristics is an ancient idea and goes by several names. The ideas behind this term are also called the Law of Use and Disuse and Lamarckianism after the French scientist Jean-Baptiste Lamarck. The idea behind acquired characteristics is that if an animal “acquired” a trait in its lifetime, it would be passed to its offspring.

Common analogies to explain this idea include the idea that if a horse had large muscles through hard and strenuous work, its offspring would inherit these muscles. However, the Law of Use and Disuse also meant that if an animal stopped using some part of its body, it would not manifest in the offspring. If we follow this line of thinking, if the person who cannot use their sense of smell has children, then this implies that the children will not be able to smell either. This is possible but not guaranteed.

Charles Darwin also adopted acquired characteristics in the development of his Theory of Evolution. However, a few years after his death, August Weisman conducted an experiment using mice. In the experiment, Wiesman cut off the tails of the mice and then had the mice reproduce. The hypothesis was if the parental mice did not have tails, then the offspring would not have tails.

After cutting off the tails of mice for 20 generations, Wiesman found that the offspring were always born with tails. This simple experiment disproves the ideal of disuse and, by implication, the use aspect as well. Naturally, all this was happening when an understanding of genetics was in its infancy and thus did not wholly negate Darwin’s Theory of Evolution.

Natural Selection

One of the main pillars of evolution is natural selection which states that the strong reproduce and pass on their traits to their offspring and the weak are not as successful for this. Opponents of evolution say that natural selection only selects variation within a species and does not create or generate new species. For example, a dog change color, grow larger or smaller, faster or slower, but it is still a dog. The local environment plays a role in manifesting traits, but it does not necessarily create new genes.

The same argument is supported by artificial breeding. People can change the appearance and even the behavior of animals through breeding. Racehorses, show dogs, milk-producing cows are all results of artificial breeding. Yet, in each example, a horse is still a horse, a dog is a dog, and a cow is still a cow.

There are also limits on variability. For example, there are natural limits in place genetically for animals and plants in terms of such traits like size, color, shape, etc. For example, apples range in size from that of a golf ball to up to four pounds. Whether an apple can evolve to the size of a ton over the course of millions or billions of years is a hypothesis that no scientist will live long enough to test.

Mutations happen naturally, but for an animal to grow a tail or lose an eye or develop the ability to fly, it would take more than one error in a long line of genetic code. Instead, it would take the changing of thousands of letters that have to be wrong in the right location and the right sequence.

The probability of this happening is not zero, and it could happen over millions of years. This requires a goal-directed approach that is being conducted randomly. It also assumes that the environment remains highly unchanged for long periods of time. This means no major changes in the climate, no catastrophic natural disasters, no dangerous diseases, etc. The changes also must be beneficial, and the organism must be lucky enough to reproduce, which is not a given—considering the time required and the need for some general stability, it would be difficult to conduct an experiment that confirms this.

IF, AND, & OR Functions in Excel VIDEO

In the video below we have an exciting introduction to several functions that are related to Boolean logic. Boolean logic is essential statements in which the only answer can be TRUE or FALSE. A lot of computer programing is based on this dichotomous idea.

For our purposes, we are going to learn how to employ the IF, AND, & OR Functions in Excel.

Naming Cells and Cell Ranges in Excel VIDEO

Most objects have names. People, places, things and in general most nouns have a name that is used to refer to them. However, computer coding can be much more boring, especially inside Excel. For example, C1 means nothing to most of us and C25:D25 means nothing as well. Fortunately, Excel allows a way to avoid this through name cells. In this post we will look at Naming cells and cell ranges in Excel in the video below.

Spontaneous Generation and Evolution

This post will look at the origins of spontaneous generation, how it was eventually disproven, and the rise of evolution in its place.

History of Spontaneous Generation

Spontaneous generation was the belief that living organisms could come from nonliving matter. This theory of life was believed for over 2,000 years until the work of Louis Pasteur and Charles Darwin in the late1850’s. The ideas of spontaneous generation begin in ancient Greece.

A presocratic philosopher named Anaximander is believed by many to be the first purpose that life began spontaneously, around the 5-6th century BCE. In so doing, Anaximander removed the agency of the Greek gods in the creation of man. About200 years later, Aristotle expanded Anaximander’s thoughts in several books that proposed spontaneous generation.

By the middle ages and the enlightenment, several experiments claimed to prove the validity of spontaneous generation. Below are several examples, along with some of the errors in the conclusions.

  • Jan Baptist van Helmont noted that trees grew bigger without any noticeable decrease in the soil around the tree. This indicated to him that the tree was growing spontaneously when the reality was that scientists were not yet familiar with the mechanisms of photosynthesis.
  • Van Helmont also mentions an experiment with wheat. He stated that if you put wheat in a jar and wrapped it in dirty wet underwear, a mouse would “appear” and eat the wheat. In actuality, the mouse would crawl inside when nobody was looking to eat the wheat.
  • Another experiment involved the fact that rotten meat would start to have maggots consume it. With the invention of the microscope, scientists realized that flies were laying eggs on the meat, and that was where the maggots came from. In addition, the experiment was further disproven by wrapping the rotten meat in cheesecloth which prevented the flies from laying their eggs on the meat. Francesco Redi conducted this falsification in 1668.

All of the examples above sowed seeds of doubt, but scientists often would not accept this evidence. This was partly because spontaneous generation was an old and established theory and firmly entrenched as the answer for the origins of life. Rejecting this was difficult personally and professionally, and one did not stand to gain much for this sacrifice. This all began to change with the work of Louis Pasteur.

Louis Pasteur

Pasteur had a radical idea at the time. He proposed to test the theory of spontaneous generation. He did a variation of the pond scum observation that supposedly supported spontaneous generation. Supporters of spontaneous generation stated that the green stuff (algae) grows by itself along with other things in the water, which provided additional evidence of life developing spontaneously. This same scum would grow even in water that was boiled first and then left outside long enough.

Pasteur conducted an experiment in which he placed chicken broth inside a flask. He then boiled the chicken broth to kill anything that was in it. What was different in this experiment from others was that flask had an s-shape top. This s-shape prevented anything from the air from getting inside the chicken broth because this would involve the particles traveling from the sky and then up the s-shape top of the flask.

Pasteur found that nothing ever grew inside the chicken broth. He replicated the experiment in different locations, elevations, weather, etc., and continued to get the same results. When he shared his results, it was the final nail in spontaneous generation. Others had provided evidence, but Pasteur provided evidence at a microbial level. Pasteur was developing his germ theory and was looking to disprove spontaneous generation to strengthen his germ theory position. However, he also had sunk the main view on the origin of life in the process. All this happened in the year 1859.

Darwin & Evolution

Naturally, scientists were distraught at the loss of spontaneous generation. Now the question was, where did humans come from? If life comes from life, does this mean that there is some supernatural explanation for life? Acknowledging a supernatural power that cannot be observed and tested is considered unscientific; however, in one of the incredible coincidences of scientific history, Charles Darwin published his theory on evolution in 1859. In other words, the same year that spontaneous generation was disproven scientifically, another explanation for the development of life was already on the scene.

There had been rumbles of evolution in the past, such as Lamarckianism, Catastrophism, and Uniformitarianism. The difference now was that the audience was much more receptive to another explanation after the most established view was destroyed. Suddenly, Darwin’s theory became the primary explanation for explaining life.

Darwin’s theory of evolution is the main explanation of the origin of life in the scientific community. It has achieved perhaps the same unquestioned standard of acceptance as spontaneous generation. A significant difference between spontaneous generation and evolution is that it is impossible to test evolution. You cannot do an experiment to prove or disprove it. Everything that happens in evolution happens millions of years ago or takes millions of years to happen.

There is observational evidence of evolution from million years ago, but two people can see the same data and come to different conclusions, especially when they are observing things rather than actively causing something to happen, such as in an experiment. Pasteur’s experiment can still be performed today, and the results will not change. Such an experiment (that develops new species over time) is still waiting to happen for evolution, and thus the cause-effect standard of an experiment