Hello Folks,
im after some help with excel.
i have a spreadsheet which i can post a link to download if it would help but here is a picture which hopefully will help.
basically what i want to do is copy the rows to the appropriate worksheet based on the values from the G column.
i have it working but every time i run the macro it copies the same rows again.
i basically want it to copy the row and add a number 1 to the duplicate column and then the next time i run it, it ignores the the rows with a number 1 in the duplicate column.
this is the code i have working so far (only have it copying to the first 2 worksheets at the moment to keep it smaller)
Sub Copy()
Dim wsSource As Worksheet
Dim wsRhisiart As Worksheet
Dim wsMarc As Worksheet
Dim wsGrahamIan As Worksheet
Dim wsAdele As Worksheet
Dim wsEther As Worksheet
Dim wsJaspal As Worksheet
Dim wsMartin As Worksheet
Dim lngDestinRow As Long
Dim rngSource As Range
Dim rngCel As Range
Set wsSource = Sheets("Main") 'Edit "Sheet1" to your source sheet name
Set wsRhisiart = Sheets("Rhisiart")
Set wsMarc = Sheets("Marc")
Set wsGrahamIan = Sheets("Graham & Ian")
Set wsAdele = Sheets("Adele")
Set wsEsther = Sheets("Esther")
Set wsJaspal = Sheets("Jaspal")
Set wsMartin = Sheets("Martin")
With wsSource
'Following line assumes column headers in Source worksheet so starts at row6
Set rngSource = .Range(.Cells(5, "F"), .Cells(.Rows.Count, "F").End(xlUp))
For Each rngCel In rngSource
If rngCel.Value = "Rhisiart" Then
With wsRhisiart
lngDestinRow = .Cells(.Rows.Count, "F").End(xlUp).Offset(1, 0).Row
rngCel.EntireRow.Copy Destination:=wsRhisiart.Cells(lngDestinRow, "A")
End With
End If
Next rngCel
For Each rngCel In rngSource
If rngCel.Value = "Marc" Then
With wsMarc
lngDestinRow = .Cells(.Rows.Count, "F").End(xlUp).Offset(1, 0).Row
rngCel.EntireRow.Copy Destination:=wsMarc.Cells(lngDestinRow, "A")
End With
End If
Next rngCel
End Sub
im after some help with excel.
i have a spreadsheet which i can post a link to download if it would help but here is a picture which hopefully will help.
basically what i want to do is copy the rows to the appropriate worksheet based on the values from the G column.
i have it working but every time i run the macro it copies the same rows again.
i basically want it to copy the row and add a number 1 to the duplicate column and then the next time i run it, it ignores the the rows with a number 1 in the duplicate column.
this is the code i have working so far (only have it copying to the first 2 worksheets at the moment to keep it smaller)
Sub Copy()
Dim wsSource As Worksheet
Dim wsRhisiart As Worksheet
Dim wsMarc As Worksheet
Dim wsGrahamIan As Worksheet
Dim wsAdele As Worksheet
Dim wsEther As Worksheet
Dim wsJaspal As Worksheet
Dim wsMartin As Worksheet
Dim lngDestinRow As Long
Dim rngSource As Range
Dim rngCel As Range
Set wsSource = Sheets("Main") 'Edit "Sheet1" to your source sheet name
Set wsRhisiart = Sheets("Rhisiart")
Set wsMarc = Sheets("Marc")
Set wsGrahamIan = Sheets("Graham & Ian")
Set wsAdele = Sheets("Adele")
Set wsEsther = Sheets("Esther")
Set wsJaspal = Sheets("Jaspal")
Set wsMartin = Sheets("Martin")
With wsSource
'Following line assumes column headers in Source worksheet so starts at row6
Set rngSource = .Range(.Cells(5, "F"), .Cells(.Rows.Count, "F").End(xlUp))
For Each rngCel In rngSource
If rngCel.Value = "Rhisiart" Then
With wsRhisiart
lngDestinRow = .Cells(.Rows.Count, "F").End(xlUp).Offset(1, 0).Row
rngCel.EntireRow.Copy Destination:=wsRhisiart.Cells(lngDestinRow, "A")
End With
End If
Next rngCel
For Each rngCel In rngSource
If rngCel.Value = "Marc" Then
With wsMarc
lngDestinRow = .Cells(.Rows.Count, "F").End(xlUp).Offset(1, 0).Row
rngCel.EntireRow.Copy Destination:=wsMarc.Cells(lngDestinRow, "A")
End With
End If
Next rngCel
End Sub