Remove Else statement

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings,

The following macro works great, and I only want to reduce the size of it. It was originally to be used if other text were to be included in the target cell. However, now there will always only be one string of text, so the "Else" statement is no longer needed. I could just keep it as it is but I think it would be better to trim down the maco if I can. Thank you very much.

The Macro is:

VBA Code:
Sub Foreign_ACFT()
    Dim i As Long
    For i = 1 To ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
        Select Case Left(ActiveSheet.Cells(i, 1).Value, 3)
            Case "UAF", "RRR", "IFC", "ASY", "LHO", "KAF"
               
If ActiveSheet.Range("G" & i) = "" Then
 ActiveSheet.Range("G" & i) = "FOREIGN"
      Else
ActiveSheet.Range("G" & i) = ActiveSheet.Range("G" & i) & "FOREIGN"
    End If
    End Select
Next i

End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Then why not delete it?
Yes, indeed not sure if I could delete
Excel Formula:
Else
ActiveSheet.Range("G" & i) = ActiveSheet.Range("G" & i) & "FOREIGN"
    End If
    End Select

In addition I would no longer need the
Excel Formula:
If ActiveSheet.Range("G" & i) = "" Then
those cells are going to be blank; I don't need to stipulate that. I just don't want to ruin anything.


Thank you,
 
Upvote 0
Have you tries removing the Else portion & running it on a copy of your data?
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,066
Members
449,090
Latest member
fragment

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top