Thank you so much once again ! I am starting and I am really unsure of the meaning of coding (Just trying by copy and past of examples, I find)
Private Sub CommandButton1_Click()
Dim lastRow As Long
Dim r As Long
'Find last row in column AC with data
lastRow = Cells(Rows.Count, "AC").End(xlUp).Row
'Loop through all rows in column AC, starting with row 2
For r = 2 To lastRow
' Check to see if value is EU Country
If Cells(r, "AC") = "Germany" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Italy" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "France" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Spain" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Portugal" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Belgium" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Netherlands" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Austria" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Croatia" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Czech Republic" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Denmark" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Estonia" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Finland" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Greece" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Hungary" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Ireland" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Latvia" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Lithuania" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Luxembourg" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Malta" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Poland" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Romania" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Slovakia" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Slovenia" Then Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Sweden" Then Cells(r, "AD") = "EU Country"
Else
Cells(r, "AD") = "Non-EU Country"
End If
Next r
End Sub
I am trying to launch it but I received the error message "Compile Error: Else without If"
Should I add to the code Sub Else_Without_If()
I actually fix this but then I have the error message "Compile error: Next without For"
Private Sub CommandButton1_Click()
Dim lastRow As Long
Dim r As Long
'Find last row in column AC with data
lastRow = Cells(Rows.Count, "AC").End(xlUp).Row
'Loop through all rows in column AC, starting with row 2
For r = 2 To lastRow
' Check to see if value is EU Country
If Cells(r, "AC") = "Germany" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Italy" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "France" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Spain" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Portugal" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Belgium" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Netherlands" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Austria" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Croatia" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Czech Republic" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Denmark" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Estonia" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Finland" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Greece" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Hungary" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Ireland" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Latvia" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Lithuania" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Luxembourg" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Malta" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Poland" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Romania" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Slovakia" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Slovenia" Then
Cells(r, "AD") = "EU Country"
If Cells(r, "AC") = "Sweden" Then
Cells(r, "AD") = "EU Country"
'ending to see if value is EU Country
Else
Cells(r, "AD") = "Non-EU Country"
End If
Next r
End Sub