Try this code
Option Explicit
Sub update_POI()
Dim lrow As Long, i As Long, startrange As Long, val As Long, lcol As Long
Application.ScreenUpdating = False
With Worksheets("Sheet1")
lrow = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 1 To lrow
If .Range("A" & i).Value Like "BEG*" Then
startrange = i
ElseIf .Range("A" & i).Value Like "PO1*" Then
val = Mid(.Range("A" & i).Value, 7, 1)
lcol = .Range("IV" & startrange).End(xlToLeft).Column
.Cells(startrange, lcol + 1).Value = val
End If
Next i
End With
MsgBox "Done"
Application.ScreenUpdating = True
End Sub
Copy the Excel VBA code
Select the workbook in which you want to store the Excel VBA code
Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
Choose Insert | Module
Where the cursor is flashing, choose Edit | Paste
To run the Excel VBA code:
Choose Tools | Macro | Macros
Select a macro in the list, and click the Run button
Bookmarks