Link to home
Start Free TrialLog in
Avatar of boukaka
boukakaFlag for Canada

asked on

set value of cell to the right of the last cell in a range

I am trying to set the value in the cell to the right of the last cell in a range but it isn't working. Can someone see what I'm doing wrong?

Set oWorkbook = Workbooks.Open(TextFile)
       
    Set oRange = ActiveWorkbook.Worksheets(1).UsedRange
       
    For i = 1 To oRange.Rows.Count
        Set oCurRow = oRange.Rows(i)
        For Each oCell In oCurRow.Cells
            If oCell.Value = sCusip Then
                oCurRow.Columns(i, oCurRow.Columns.Count).Offset(0, 1).Value = "Y"
            End If
        Next
    Next
ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of boukaka

ASKER

Thank you!