Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Please help with a Loop...
I'm need some help with this project. Here's what I'm trying to accomplish: 1. An employee name is in column A 2. An employee id number is in column B 3. Several rows between employees are blank in columns A & B. 4. When each employee is found, copy the employee id number down in each row until the next employee is found in column A. 5. Repeat the operation until all employee id numbers are copied in the range. Example: Range is dynamic. Will change from sheet to sheet. Conditions are as follows: If A2 = value And B2 = value Then 'Iterate down rows from A3 until < ''' 'Copy each cell in column B = B2 'This is the employee id number Thanks in advance for all your help!! -- mthomas ------------------------------------------------------------------------ mthomas's Profile: http://www.excelforum.com/member.php...o&userid=25649 View this thread: http://www.excelforum.com/showthread...hreadid=486951 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Please help with a Loop...
Hi,
Try this (test data first!). There will only be one row for the last employee - is this correct? HTH Sub AddEmployeeNumber() Dim lastrow As Long, r As Long lastrow = Cells(Rows.Count, "A").End(xlUp).Row For r = 3 To lastrow If Cells(r, 1) = "" Then Cells(r, 2) = Cells(r - 1, 2) Next r End Sub "mthomas" wrote: I'm need some help with this project. Here's what I'm trying to accomplish: 1. An employee name is in column A 2. An employee id number is in column B 3. Several rows between employees are blank in columns A & B. 4. When each employee is found, copy the employee id number down in each row until the next employee is found in column A. 5. Repeat the operation until all employee id numbers are copied in the range. Example: Range is dynamic. Will change from sheet to sheet. Conditions are as follows: If A2 = value And B2 = value Then 'Iterate down rows from A3 until < ''' 'Copy each cell in column B = B2 'This is the employee id number Thanks in advance for all your help!! -- mthomas ------------------------------------------------------------------------ mthomas's Profile: http://www.excelforum.com/member.php...o&userid=25649 View this thread: http://www.excelforum.com/showthread...hreadid=486951 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Please help with a Loop...
Works great! Appreciate you taking the time. Have a great day! -- mthomas ------------------------------------------------------------------------ mthomas's Profile: http://www.excelforum.com/member.php...o&userid=25649 View this thread: http://www.excelforum.com/showthread...hreadid=486951 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Loop Function unable to loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
For/Loop skipping one value in loop only | Excel Programming | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming |