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

I have a large worksheet with about 700 employees; each employee has at least
1 row for every date of the month, and several columns. For each employee, I
would like to search Column C for 2 specific values. If those values are
found on any row for that employee, then the value in Column C should be
copied to the corresponding row in Column D for that employee (even if that
row does not contain the value searched for). Example:

The value being searched for (RSV) is found in at least one of the rows for
employee # 123. So, column C for ALL rows (even without RSV) are copied to
the corresponding column D for that employee. The value RSV is not found in
column C at all for employee 456, so column D for that employee is left alone.

Original:
A B C D
123 1/1 RSV aaaa
123 1/2 OFF bbbb
123 1/3 OFF cccc
456 1/1 OFF OFF
456 1/2 aaaa aaaa
456 1/3 bbbb bbbb

Result:
A B C D
123 1/1 RSV RSV
123 1/2 OFF OFF
123 1/3 OFF OFF
456 1/1 OFF OFF
456 1/2 aaaa aaaa
456 1/3 bbbb bbbb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro question

What was wrong with this code Iposted to your previous request?

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


"Rich" wrote:

I have a large worksheet with about 700 employees; each employee has at least
1 row for every date of the month, and several columns. For each employee, I
would like to search Column C for 2 specific values. If those values are
found on any row for that employee, then the value in Column C should be
copied to the corresponding row in Column D for that employee (even if that
row does not contain the value searched for). Example:

The value being searched for (RSV) is found in at least one of the rows for
employee # 123. So, column C for ALL rows (even without RSV) are copied to
the corresponding column D for that employee. The value RSV is not found in
column C at all for employee 456, so column D for that employee is left alone.

Original:
A B C D
123 1/1 RSV aaaa
123 1/2 OFF bbbb
123 1/3 OFF cccc
456 1/1 OFF OFF
456 1/2 aaaa aaaa
456 1/3 bbbb bbbb

Result:
A B C D
123 1/1 RSV RSV
123 1/2 OFF OFF
123 1/3 OFF OFF
456 1/1 OFF OFF
456 1/2 aaaa aaaa
456 1/3 bbbb bbbb

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
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Macro question Gilbert Excel Discussion (Misc queries) 7 November 8th 07 06:15 PM
question on macro Harry Excel Discussion (Misc queries) 8 April 13th 06 04:25 PM
macro question Cacoe[_2_] Excel Programming 3 November 21st 05 04:15 PM
question on macro kara Excel Programming 2 November 18th 05 06:17 PM


All times are GMT +1. The time now is 09:09 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"