Hi guys,
I was just wondering if anyone is able to help me out with this code?
Currently my code copies all the rows from Sheet1 where column A contains the word "Audit" (this is the value specified in cell T1 in the code). and it appends these rows to the rows in Sheet2.
However I now need to amend this code so that it not only copies across those rows with "Audit" specified in column A but it also only copies across x number of rows which matches the value specified in C9. C9 is a formula which calculates how many records to audit, so if the value in C9 says 9, I would like to only copy across the first 9 rows in Sheet1 where column A contains the word 'Audit'.
Here is my current code:
Thank you so much for any help you are able to provide.
I was just wondering if anyone is able to help me out with this code?
Currently my code copies all the rows from Sheet1 where column A contains the word "Audit" (this is the value specified in cell T1 in the code). and it appends these rows to the rows in Sheet2.
However I now need to amend this code so that it not only copies across those rows with "Audit" specified in column A but it also only copies across x number of rows which matches the value specified in C9. C9 is a formula which calculates how many records to audit, so if the value in C9 says 9, I would like to only copy across the first 9 rows in Sheet1 where column A contains the word 'Audit'.
Here is my current code:
Code:
Sub CopyCells()
Dim AB As Long, CD As Long, MyRange As Range
AB = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For Each MyRange In Sheets("Sheet1").Range("A15:A" & AB)
If MyRange.Value = Sheets("Sheet1").[T1] Then
With Sheets("Sheet2")
CD = .Cells(Rows.Count, 1).End(xlUp).Row
.Cells(CD + 1, 1).Resize(, 113).Value = Sheets("Sheet1").Cells(MyRange.Row, 1).Resize(, 113).Value
End With
End If
Next MyRange
End Sub
Thank you so much for any help you are able to provide.