Thread: Fill down a row
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Joanne Joanne is offline
external usenet poster
 
Posts: 121
Default Fill down a row

Thank you again for your help. You make my job easier with your
willingness and promptness in answering my sos
I want to understand the code so that I can better learn to use it
myself.

This code looks like it looks at the number of rows on the worksheet,
then reads each cell value. If the value is nothing, then it selects the
cell and copies something to it.

What I don't get is how does it know what to copy to the empty cells and
how does it know when to read a cell that is not empty and then start
copying that. I think I understand that no variable is needed because we
are simply copying what we found in the cell. Again though, how did we
find it!!??? I am so confused.

ActiveCell.End(xlUp).Copy cell
This is the line I don't understand well

Thank you
Joanne


GTVT06 wrote:

On Jan 16, 5:13 pm, Joanne wrote:
WinXP Pro MSOffice 2003 Pro

I have a spreadsheet with hundreds of rows and 15 columns

Col A holds Company name
Each Company can have any number of line items on the spreadsheet
Col A has the Company name in the company's first line item only, then
the rest of Col A is empty until the company name changes.

I need to get Company name in Col A on each and every line item for the
company. I know I need to read the Company Name, then recognize cells in
col A that are empty (up to a new company name), copy the company name
into those cells, proceed to the next cell and read the next company
name, recognize the empty cells for that company, copy the name there
and etc until I reach the end of the spreadsheet.

Could someone help me with this, or point me to an example somewhere so
I can help myself?

I sure appreciate your time and effort.
Thanks
Joanne



hello, try this:

Sub filldwn()
Dim cell As Range
'adjust the range below to fit your needs
For Each cell In Range("A1:A50")
If cell.Value = "" Then
cell.Select
ActiveCell.End(xlUp).Copy cell
End If
Next cell
End Sub