Dear all ,
i have a problem in looping rows.
i have below macro that should looping column B from row13 ,instead is also looping row12 (that correspond to my table heather) ...
i have tried the code below but not working ...
can someone help please .
basicaly i need to find last row of column B and loop back untill row13 .
Many tks to anyone for help .
here below the code :
i have a problem in looping rows.
i have below macro that should looping column B from row13 ,instead is also looping row12 (that correspond to my table heather) ...
i have tried the code below but not working ...
can someone help please .
basicaly i need to find last row of column B and loop back untill row13 .
Many tks to anyone for help .
here below the code :
VBA Code:
Dim lRow As Long
Dim Ring As Range
lRow = Cells(Rows.Count, 2).End(xlUp).Row
For Each Ring In Range("B13:B" & lRow)
ActiveSheet.Unprotect
Dim Rng As Range
Dim foundrange As Range
Dim wb As Workbook
Dim fFilename As String
test1 = Ring.Value
Ring.EntireRow.Copy
Ring.Offset(0, 18).Value = "OK"
fFilename = "X:\CargoluxItalia\COMMON\RISK ANALYISIS\riskregister.xlsm"
SetAttr fFilename, vbNormal
Set wb = Workbooks.Open(fFilename)
Set foundrange = Workbooks("riskregister").Sheets("sheet1").Range("b:b").Find(test1, , xlValues, xlWhole, xlByRows, xlNext, False, False, False)
If Not foundrange Is Nothing Then
Workbooks("riskregister").Sheets("Sheet1").Select
foundrange.Offset(0, -1).Select
selection.PasteSpecial
Application.CutCopyMode = False
Else
LastRow = Workbooks("riskregister").Sheets("sheet1").Cells(Rows.Count, 2).End(xlUp).Row + 1
Workbooks("riskregister").Sheets("Sheet1").Rows(LastRow).PasteSpecial
Application.CutCopyMode = False
Ring.Offset(0, 12).Value = OK
End If
Next