Hi,
I’m having a little trouble with a VBA and I’d be very grateful for some help!
I am transferring a whole row/columns A – J when the entry ‘yes’ is entered in column E from sheets named after peoples first names e.g. Geoff, Peter, Emma etc. The sheet that these transfer to is name ‘Indemnified Summary’
Basically, I’ve been using the below code which when I run, transfers the row and contents exactly how I’d like.
Sub copyPaste()
Dim ws As Worksheet
Dim wt As Worksheet
Set ws = Sheets("Geoff")
Set wt = Sheets("Indemnified Summary")
Dim i As Long
Dim lr As Long
lr = ws.Range("E" & Rows.Count).End(xlUp).Row
Dim lt As Long
For i = 1 To lr
lt = wt.Range("A" & Rows.Count).End(xlUp).Row
If ws.Range("E" & i) = "yes" Then
ws.Range("E" & i).EntireRow.Copy wt.Range("A" & lt + 1)
End If
Next i
End Sub
However, there are a few things I’d like to alter, but don’t know how.
If anyone can help I’d be very very very grateful!
I’m having a little trouble with a VBA and I’d be very grateful for some help!
I am transferring a whole row/columns A – J when the entry ‘yes’ is entered in column E from sheets named after peoples first names e.g. Geoff, Peter, Emma etc. The sheet that these transfer to is name ‘Indemnified Summary’
Basically, I’ve been using the below code which when I run, transfers the row and contents exactly how I’d like.
Sub copyPaste()
Dim ws As Worksheet
Dim wt As Worksheet
Set ws = Sheets("Geoff")
Set wt = Sheets("Indemnified Summary")
Dim i As Long
Dim lr As Long
lr = ws.Range("E" & Rows.Count).End(xlUp).Row
Dim lt As Long
For i = 1 To lr
lt = wt.Range("A" & Rows.Count).End(xlUp).Row
If ws.Range("E" & i) = "yes" Then
ws.Range("E" & i).EntireRow.Copy wt.Range("A" & lt + 1)
End If
Next i
End Sub
However, there are a few things I’d like to alter, but don’t know how.
- Each time it runs, it duplicates on the sheet it transfers to – I only need each row to transfer once!
- I’d like to add other sheets to the same code so it applies to all needed, but I can’t seem to make that work. So as well as “Geoff” I’d like “Peter” and “Emma” and so on.
- Is there a code to make each transfer either
- automatically whenever entries are made into source sheet or
- whenever the workbook opens after being closed.
If anyone can help I’d be very very very grateful!