IF Statement to change codes
Tag : excel , By : Alex S
Date : March 29 2020, 07:55 AM
I hope this helps you . I am not sure what you are trying to achieve but this is one way of replacing text MU999 with R. Martinez within rows 2 and 3000 in column E Sub Main()
Dim c As Range
For Each c In Range("E2:E3000")
If StrComp(c, "MU999", vbTextCompare) = 0 Then
c = "R. Martinez"
End If
Next
End Sub
Sub Main()
Dim c As Range
For Each c In Range("E2:E3000")
If StrComp(c, "MU999", vbTextCompare) = 0 Then
c = "R. Martinez"
ElseIf StrComp(c, "MU111", vbTextCompare) = 0 Then
c = "replaced with M. Martinez"
ElseIf StrComp(c, "MU666", vbTextCompare) = 0 Then
c = "666 is not evil!"
End If
Next
End Sub
Sub Main()
Dim c As Range
For Each c In Range("E2:E3000")
Select Case UCase(c)
Case "MU999"
c = "R. Martinez"
Case "MU111"
c = "replaced with M. Martinez"
Case "MU666"
c = "666 is not evil!"
End Select
Next
End Sub
|
Can we add a statement in between MATLAB codes?
Date : March 29 2020, 07:55 AM
With these it helps Is it possible to add statements in between the codes. , You need to comment those statements like this r(:,1) = a(:,1) ... % this is a constant
- a(:,2); % this is a variable
|
what does the codes with the 'with' statement do?
Date : March 29 2020, 07:55 AM
it should still fix some issue When so many examples are non-self explanatory and the documentation not too helpful, Beginning Python I came across with statement used in a code as such: , I commented to try explain; #this is your standard method definition
def r_f(fn, n, vl):
#these are local variables
cn, rd = 0, 0
#we are saying;
#in the scope of this with statement, the variable f
#is equal to the file object returned by open
with open(fn, 'r') as f:
#for every line in the file
#(because readlines returns a list of all the lines)
for value in f.readlines():
#increment this variable by 1
rd += 1
#if rd is greater than n
if rd > n:
#break out of this loop
break
#if the integer representation of the line we read
#is equal to v1
if int(value) == vl:
#then increase this variable by 1
cn += 1
#we return this value to the function that called us
return cn
|
Excel if statement to R codes
Tag : r , By : Ryan Adriano
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I am new to R and trying to use R to run the report I am currently doing in excel. Most of the topics here have been so helpful to me translating excel formula to R codes, however, I am struggling to generate codes for below excel if statement , We can do a nested ifelse after reading the dataset df1 <- read.csv("yourfile.csv", stringsAsFactors=FALSE)
ifelse(df1[,7]=="SEA" & df1[,6] %in% c("FCL", "BCN"),
df1[,35]*40, ifelse(df1[,7]=="AIR", df1[,36]*66, NA))
|
Why is a Bash variable empty inside of an if statement empty, but not outside of the if statement?
Tag : linux , By : Bimal Poudel
Date : March 29 2020, 07:55 AM
Any of those help , Use here-doc as this: cat > variables.sh <<-'EOF1'
#!/bin/bash
echo "Please enter your first name:"
read -e -i "Bob" FIRST_NAME
echo "Please enter your last name:"
read -e -i "Marley" LAST_NAME
echo "First name: $FIRST_NAME"
echo "Last name: $LAST_NAME"
if [[ "$FIRST_NAME" == "Bob" ]] ; then
echo "Last name: $LAST_NAME"
fi
EOF1
|