Copying Data from Workbooks("Sheet1").Worksheets("Sheet1") Range("A5:BBC5") if that row has a word "king" it should copy the data of complete row and paste it to Workbooks("Sheet2").Worksheets("Sheet2") Range("K10") that sheet.
I am unable to figure it out that why my code is not working.
any help would be highly appreciated.
Code
Sub CopyRows()
Dim rightend As Integer
Dim x As Integer
Dim c As Range
Dim Source As Worksheet
Dim Target As Worksheet
Set Source = Workbooks("Sheet1").Worksheets("Sheet1")
Set Target = Workbooks("Sheet2").Worksheets("Sheet2")
rightend = Source.Range("L" & Columns.Count).End(xlRight).Columns: x = 1
For Each c In Source.Range("A5:BBC5" & rightend)
If c.Value = "king" Then
c.EntireRow.Copy Worksheets("sheet2").Range("A" & x)
x = x + 1
End If
Next c
Targte.Range("K10").Select
ActiveSheet.Paste
End Sub
Display More