#1   Report Post  
Posted to microsoft.public.excel.misc
BeJay
 
Posts: n/a
Default help with a loop

Hi, Probably very simple but not for me! Have searched for similar
examples but haven't found anything that I will find easily
"Tweak-able"! I need some help with a loop that needs to copy data
down blank cells in a column until there is new data there again.

Details:- I have a column A populated with an order number, column b
with an area code and column c with individual item lines. The amount
of item lines may be different for each separate order. I need the
order number and area number to be copied down the blank cells until
the next order number, which is then to be copied down to the next one
and so on. (same for area code)

B100010 R12 099998
099999
101311
B100505 R11 101313
101315
101317
101319
101501
101503
B20902 R41 101505
101507
101509
101511
101513
101515

Can I define a macro to do this? Otherwise I will be going into some
pretty un-chartered VBA territory. I assume there may need to be loop
statement ( which I could probably cope with - just about!) but am
struggling to work out how I tell it to copy into the blank cells, the
text from the last cell in that column that wasn't blank.

Anybody Help??? Thanks in advance :-)

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default help with a loop

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
For i = 2 To iLastRow
If Cells(i, "A").Value = "" Then
Cells(i, "A").Value = Cells(i - 1, "A").Value
Cells(i, "B").Value = Cells(i - 1, "B").Value
End If
Next i

End Sub



--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"BeJay" wrote in message
ups.com...
Hi, Probably very simple but not for me! Have searched for similar
examples but haven't found anything that I will find easily
"Tweak-able"! I need some help with a loop that needs to copy data
down blank cells in a column until there is new data there again.

Details:- I have a column A populated with an order number, column b
with an area code and column c with individual item lines. The amount
of item lines may be different for each separate order. I need the
order number and area number to be copied down the blank cells until
the next order number, which is then to be copied down to the next one
and so on. (same for area code)

B100010 R12 099998
099999
101311
B100505 R11 101313
101315
101317
101319
101501
101503
B20902 R41 101505
101507
101509
101511
101513
101515

Can I define a macro to do this? Otherwise I will be going into some
pretty un-chartered VBA territory. I assume there may need to be loop
statement ( which I could probably cope with - just about!) but am
struggling to work out how I tell it to copy into the blank cells, the
text from the last cell in that column that wasn't blank.

Anybody Help??? Thanks in advance :-)



  #3   Report Post  
Posted to microsoft.public.excel.misc
BeJay
 
Posts: n/a
Default help with a loop

Thanks Bob - great help.

  #4   Report Post  
Posted to microsoft.public.excel.misc
BeJay
 
Posts: n/a
Default help with a loop

Thanks Bob - great help.

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
how to put a loop in a macro? Khoshravan New Users to Excel 4 May 14th 06 01:22 PM
Loop time seems dependent on unrelated workbook - Why? Richard Excel Worksheet Functions 2 March 30th 06 11:59 PM
Loop gone crazy Dave Peterson Excel Discussion (Misc queries) 4 December 16th 05 03:38 PM
Do Loop Noemi Excel Discussion (Misc queries) 0 December 8th 05 10:43 PM
loop trough e-mail address list to send task lists with outlook Paul. Excel Discussion (Misc queries) 2 April 14th 05 11:48 AM


All times are GMT +1. The time now is 08:42 PM.

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

About Us

"It's about Microsoft Excel"