Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Macro question

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.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro question

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


"Don Guillett" wrote:

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"richzip" wrote in message
...
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Yet another macro question cvgairport Excel Discussion (Misc queries) 3 April 27th 10 06:47 PM
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Macro If Then Question mslabbe Excel Programming 4 January 28th 08 08:02 PM
Macro Question Vick Excel Discussion (Misc queries) 1 November 27th 07 02:58 PM
macro question scott23 Excel Programming 1 March 3rd 04 06:06 PM


All times are GMT +1. The time now is 07:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"