Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
For/Loop skipping one value in loop only Matt Jensen Excel Programming 6 January 8th 05 12:03 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 10:18 AM.

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"