farrukh
01-09-2012, 07:22 AM
Hi All,
I have a code which works perfectly , but a little issue if code does not find any value or string in column be then hangs and keep inserting rows in other sheet to match the crieteria i need that the code run on used range of column B of maste sheet.
Sub InsertRowOnMatch()
Dim vM As Variant
Dim wks As Worksheet
Dim x As Long
With Worksheets("Master_sheet")
vM = .Range("B2:B" & .Range("B2").End(xlDown).Row)
End With
For Each wks In ThisWorkbook.Worksheets
If Left(wks.Name, 1) = "K" Then
For x = 1 To UBound(vM, 1)
If wks.Cells(x + 1, 2).Value <> vM(x, 1) Then
wks.Cells(x + 1, 2).EntireRow.Insert
End If
Next x
End If
Next
End Sub
Thanks and Regards
FR
I have a code which works perfectly , but a little issue if code does not find any value or string in column be then hangs and keep inserting rows in other sheet to match the crieteria i need that the code run on used range of column B of maste sheet.
Sub InsertRowOnMatch()
Dim vM As Variant
Dim wks As Worksheet
Dim x As Long
With Worksheets("Master_sheet")
vM = .Range("B2:B" & .Range("B2").End(xlDown).Row)
End With
For Each wks In ThisWorkbook.Worksheets
If Left(wks.Name, 1) = "K" Then
For x = 1 To UBound(vM, 1)
If wks.Cells(x + 1, 2).Value <> vM(x, 1) Then
wks.Cells(x + 1, 2).EntireRow.Insert
End If
Next x
End If
Next
End Sub
Thanks and Regards
FR