Copy Specific Cells To A New Sheet On Condition

J

jenloe

Summary of Challenge: I have a workbook with two sheets, LeadTracking and
Commissions. I need to copy specific cells (not the entire row) LeadTracking
to Commissions if the value in column X is CL. The values in cells
C,D,E,J,X,L and AA need to be copied to Commissions in columns A,B,C,D, etc.
The first two rows of LeadTracking are column labels, Commissions has one row
of labels.

I have a starting point which accomplishes part of what I want to do, but it
copies the entire row, not specific cells within that row. (Note that I did
not write this code but found it via a web search). Appreciate any
suggestions.
 
L

lcaretto

Try code like the following
newRow = firstDataRow
row = firstDataRow
str = LeadTracking.Cells(row, "X").Text
Do While str <> ""
If str = "CL" Then
'repeat statement below for all cells that you want to copy
Commissions.Cells(newRow, "A").Value = _
LeadTracking.Cells(row, "C").Value
newRow = newRow + 1
End If
row = row + 1
str = LeadTracking.Cells(row, "X").Text
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top