rlundbulls23
New Member
- Joined
- Dec 21, 2024
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello,
I've been using the following successfully but now want to modify it to only copy certain columns versus the entire row. I've read various threads but stuck how to include a range or identify specific columns.
Thanks in advance for your help!!
-Bob
Sub CopyRowBasedOnCellValue()
Dim xRg As Range
Dim xCell As Range
Dim A As Long
Dim B As Long
Dim C As Long
A = Worksheets("Master").UsedRange.Rows.Count
B = Worksheets("Sold").UsedRange.Rows.Count
If B = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sold").UsedRange) = 0 Then B = 0
End If
Set xRg = Worksheets("Master").Range("D1:D" & A)
On Error Resume Next
Application.ScreenUpdating = False
For C = 1 To xRg.Count
If CStr(xRg(C).Value) = "Done" Then
xRg(C).EntireRow.Copy Destination:=Worksheets("Sold").Range("A" & B + 1)
B = B + 1
End If
Next
Application.ScreenUpdating = True
End Sub
I've been using the following successfully but now want to modify it to only copy certain columns versus the entire row. I've read various threads but stuck how to include a range or identify specific columns.
Thanks in advance for your help!!
-Bob
Sub CopyRowBasedOnCellValue()
Dim xRg As Range
Dim xCell As Range
Dim A As Long
Dim B As Long
Dim C As Long
A = Worksheets("Master").UsedRange.Rows.Count
B = Worksheets("Sold").UsedRange.Rows.Count
If B = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sold").UsedRange) = 0 Then B = 0
End If
Set xRg = Worksheets("Master").Range("D1:D" & A)
On Error Resume Next
Application.ScreenUpdating = False
For C = 1 To xRg.Count
If CStr(xRg(C).Value) = "Done" Then
xRg(C).EntireRow.Copy Destination:=Worksheets("Sold").Range("A" & B + 1)
B = B + 1
End If
Next
Application.ScreenUpdating = True
End Sub