Hi Guys,
Kindly help me with this one. I have a macro in the System Network worksheet that copy particular cells of a row if the value of a cell = Network Attack to another worksheet named Attack Report.
It's working as of this moment, but my problem is everytime the macro is run, it copies also the previously copied cells resulting into duplicates. What I want to do is when the macro runs, it skips the previously copied cells and only copy those that are not copied yet. Also, is there a way to put a button in the worksheet that will run the macro?
Sub copyData()
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long, rng As Range, c As Range, rw As Long
Set sh1 = Sheets("System Network")
Set sh2 = Sheets("Attack Report")
lr = sh1.Cells(Rows.Count, 2).End(xlUp).Row
Set rng = sh1.Range("B7:B" & lr)
For Each c In rng
If c.Value = "Network Attack" Then
rw = sh2.Cells(Rows.Count, 1).End(xlUp)(2).Row
With sh2
.Range("A" & rw) = c.Offset(0, -1).Value
.Range("B" & rw) = c.Offset(0, 1).Value
.Range("F" & rw) = c.Offset(0, 3).Value
.Range("G" & rw) = c.Offset(0, 4).Value
.Range("I" & rw) = c.Offset(0, 5).Value
.Range("J" & rw) = c.Offset(0, 6).Value
.Range("L" & rw) = c.Offset(0, 7).Value
.Range("M" & rw) = c.Offset(0, 8).Value
End With
End If
Next
End Sub
Please see attached file for your reference.
Thanks in advance
Bookmarks