1 ( 1) ( ):
Function fxr2()
Dim lRow As Long, LastRow As Long
Dim w As Workbook
Dim ws As Worksheet
Set w = ThisWorkbook
Set ws = w.Worksheets("Fixer") '<-- set the worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim type1 As String, result As String '<
' use With statement, will simplify and shorten your code later
With ws
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row '<
For lRow = 7 To LastRow
type1 = .Cells(lRow, 1).Text
Select Case type1
Case "Bail-in", "Investment", "Recapitalization", "Refinance", "Design"
result = .Cells(lRow, 1)
Case "Basel"
result = .Cells(lRow, 1) & " " & .Cells(lRow, 2) & " " & .Cells(lRow, 3) & " " & .Cells(lRow, 4) & " " & .Cells(lRow, 5)
Case "Collateral", "General", "Lower", "Upper"
result = .Cells(lRow, 1) & " " & .Cells(lRow, 2) & " " & .Cells(lRow, 3)
Case Else
result = .Cells(lRow, 1) & " " & .Cells(lRow, 2)
End Select
.Cells(lRow, 10).Value = result
Next lRow
End With
End Function
, Code 2, - 2 Case , String, :
Select Case .Cells(lRow, 4)
Case "Base", "Inte", "Tier", "v", "Ba", "Bas", "Int", "Inte", "Inter", "Tie", "Tier-", "", "Upp", "Uppe", "Upper", "I", "L", "T"
.Cells(lRow, 11) = ""
Case "Design", "Inve", "Inv", "Low", "Lowe", "Proj", "Pro", "Ref", "Refi", "Refin", "Refina", "Refinanc", "Refinance", "Stock", "Inve", "LBO", "Working", "Work", "Wor", "Gre", _
"Gree", "Green", "Interc", "Intercom", "Intercompany", "Intermed", "Refinanc", "Stoc", "No", "Pen", "Pens", "Pension", "Projec", "Project", _
"Sto", "Stoc", "w", "Wor", "Tier-1", "Tier-2"
.Cells(lRow, 11) = .Cells(lRow, 4)
End Select
, , , Select Case, Select Case.
""
Function fxr2()
Dim lRow As Long, LastRow As Long
Dim w As Workbook
Dim ws As Worksheet
Set w = ThisWorkbook
Set ws = w.Worksheets("Fixer") '<-- set the worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim type1 As String, result As String '<-- There no need to Dim them every time inside the loop
' use With statement, will simplify and shorten your code later
With ws
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row '<-- fully qualify Rows.Count with "Fixer" sheet
For lRow = 7 To LastRow
type1 = .Cells(lRow, 1).Text
Select Case type1
Case "Bail-in", "Investment", "Recapitalization", "Refinance", "Design"
.Cells(lRow, 10).Value = .Cells(lRow, 1)
Case "Basel"
.Cells(lRow, 10).Value = .Cells(lRow, 1) & " " & .Cells(lRow, 2) & " " & .Cells(lRow, 3) & " " & .Cells(lRow, 4) & " " & .Cells(lRow, 5)
Case "Collateral", "General", "Lower", "Upper"
.Cells(lRow, 10).Value = .Cells(lRow, 1) & " " & .Cells(lRow, 2) & " " & .Cells(lRow, 3)
' ===== Added the Nested case here (just for example) =====
Select Case .Cells(lRow, 4)
Case "Base", "Inte", "Tier", "v", "Ba", "Bas", "Int", "Inte", "Inter", "Tie", "Tier-", "", "Upp", "Uppe", "Upper", "I", "L", "T"
.Cells(lRow, 11) = ""
Case "Design", "Inve", "Inv", "Low", "Lowe", "Proj", "Pro", "Ref", "Refi", "Refin", "Refina", "Refinanc", "Refinance", "Stock", "Inve", "LBO", "Working", "Work", "Wor", "Gre", _
"Gree", "Green", "Interc", "Intercom", "Intercompany", "Intermed", "Refinanc", "Stoc", "No", "Pen", "Pens", "Pension", "Projec", "Project", _
"Sto", "Stoc", "w", "Wor", "Tier-1", "Tier-2"
.Cells(lRow, 11) = .Cells(lRow, 4)
End Select
' ==== End of Nested Select Case ====
Case Else
.Cells(lRow, 10).Value = .Cells(lRow, 1) & " " & .Cells(lRow, 2)
End Select
Next lRow
End With
End Function