Este es el código de Internet y se me ocurrió. Por favor, ¿podría decirme qué estoy haciendo mal? Sigo recibiendo un error que dice "no se puede usar un bucle sin un do"
Sub additions () Range(“BI1”) = “Comments” Range(“V2”).Select Do until IsEmpty(ActiveCell) If (Range(ActiveCell) = “DM”) Then ActiveCell.Offset(0,39).Select Range(ActiveCell) = “Developed Markets” ActiveCell.Offset(1,-39).Select End If Loop End Sub Option Explicit Sub Additions() Dim ws As Worksheet: Set ws = ActiveSheet ' improve! Dim srg As Range Set srg = ws.Range("V2", ws.Cells(ws.Rows.Count, "V").End(xlUp)) Dim drg As Range: Set drg = srg.EntireRow.Columns("BI") ws.Range("BI1").Value = "Comments" Dim sCell As Range Dim r As Long For Each sCell In srg.Cells r = r + 1 If CStr(sCell.Value) = "DM" Then ' is a match drg.Cells(r).Value = "Developed Markets" 'Else ' is not a match; do nothing End If Next sCell MsgBox "Additions finished.", vbInformation End Sub