Macro question

R

richzip

I would like to know if a macro can accomplish the following: I have a large
worksheet with about 600 employees, and each employee has at least 1 row for
each date of the month.

For each employee, I would like to search in Column C for one of 2 different
values (RSV, NEW). If that value is found in ANY row for that employee, it
will copy all values in column C (for that employee) to the corresponding row
in column D.

Please see first reply for an example.
 
D

Don Guillett

You could use a FINDNEXT macro(look in the vba help for FINDNEXT) to do just
that
 
J

Joel

Try this code. It uses Sumproduct on the worksheet

Sub copycolumn()

OldEmployee = 0
RowCount = 1
Start = RowCount
CopyCol = False
Do While Range("A" & RowCount) <> ""
If Range("A" & RowCount) <> Range("A" & (RowCount + 1)) Then
Employee = Range("A" & RowCount)
ColARange = "A" & Start & ":A" & RowCount
ColCRange = "C" & Start & ":C" & RowCount

RSVSumProduct = "Sumproduct(--(" & ColARange & "=" & Employee & ")," & _
"--(" & ColCRange & "=""RSV""))"

RSVResult = Evaluate(RSVSumProduct)

NewSumProduct = "Sumproduct(--(" & ColARange & "=" & Employee & ")," & _
"--(" & ColCRange & "=""NEW""))"

NewResult = Evaluate(NewSumProduct)

Result = RSVResult + NewResult

If Result > 0 Then
Range(ColCRange).Copy Destination:=Range("D" & Start)
End If

Start = RowCount + 1
End If
RowCount = RowCount + 1
Loop
End Sub
 

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

Similar Threads

macro question 0
Macro question 0
Is this macro possible? 3
Macro question 1
Macro code question 1
Help with macro 0
Macro question 0
Setting column width in a table with a macro is not working 0

Top