Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Filling Column with Numbers

If you don't want to select or fill 3000 names, try this
ActiveCell.Offset(1, 0).Activate

???
======
"Bradley Dawson" wrote in message
...
If you don't want to select or fill 3000 names, try this:

Sub dptnum()
Dim i%
i = 1
Do While Not (IsEmpty(ActiveCell) And IsEmpty(ActiveCell.Offset(1, 0)))
If Not IsEmpty(ActiveCell) Then
ActiveCell.Offset(0, -1) = i
Else
i = i + 1
End If
ActiveCell.Offset(1, 0).Activate
Loop
End Sub

Start at the top of the list with a blank column to the left of the list.
It will stop when two blank rows are encountered.

"Tom" wrote
I have the following scenario
One column in excel contains more than 3000 names
I want to fill the adjacents cells with Department Number
Fortunately all the names belonging to same department are
coming together followed by an EMPTY CELL Then the second
Department names start followed by an EMPTY CELL then
third Department names being and so on "all these under
one column"
I need to tell Excel to start filling the adjacent cell of
Dept1 names with Number 1 and continue down stream
Till it found the adjacent cell is EMPTY (in our example
the cell between Tom and James) Stop filling and Jump to
next cell and start filling with number 2 till it found
the second Empty cell stop
filling and Jump to adjacent cell and start
filling with number 3 and so on....





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Filling Column with Numbers

Your solution is great! I'm just saying that with a large list that
contains blank rows, selecting it can be almost as tedious as a fill.
Especially with some of the lists I deal with. (26K to 30K rows). So in
this code either a department number is placed next to the list or the
department number is incremented depending on if the entry is blank or not.
Then the activecell moves down one. When it gets to two blank rows it
stops. I suppose going back to the top of the list after it completes would
have been a nice touch, though.

Anyway, it worked fine when I tested it.

Questions?

"Don Guillett" wrote in message
...
If you don't want to select or fill 3000 names, try this
ActiveCell.Offset(1, 0).Activate

???
======
"Bradley Dawson" wrote in message
...
If you don't want to select or fill 3000 names, try this:

Sub dptnum()
Dim i%
i = 1
Do While Not (IsEmpty(ActiveCell) And IsEmpty(ActiveCell.Offset(1, 0)))
If Not IsEmpty(ActiveCell) Then
ActiveCell.Offset(0, -1) = i
Else
i = i + 1
End If
ActiveCell.Offset(1, 0).Activate
Loop
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Filling Column with Numbers

If you like it that way, I love it.
I guess that activate and select are two different things.

"Bradley Dawson" wrote in message
...
Your solution is great! I'm just saying that with a large list that
contains blank rows, selecting it can be almost as tedious as a fill.
Especially with some of the lists I deal with. (26K to 30K rows). So in
this code either a department number is placed next to the list or the
department number is incremented depending on if the entry is blank or

not.
Then the activecell moves down one. When it gets to two blank rows it
stops. I suppose going back to the top of the list after it completes

would
have been a nice touch, though.

Anyway, it worked fine when I tested it.

Questions?

"Don Guillett" wrote in message
...
If you don't want to select or fill 3000 names, try this
ActiveCell.Offset(1, 0).Activate

???
======
"Bradley Dawson" wrote in message
...
If you don't want to select or fill 3000 names, try this:

Sub dptnum()
Dim i%
i = 1
Do While Not (IsEmpty(ActiveCell) And IsEmpty(ActiveCell.Offset(1,

0)))
If Not IsEmpty(ActiveCell) Then
ActiveCell.Offset(0, -1) = i
Else
i = i + 1
End If
ActiveCell.Offset(1, 0).Activate
Loop
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Filling Column with Numbers

Activate and Select are very similar. As far as moving the activecell,
they're the same.

"Don Guillett" wrote in message
...
If you like it that way, I love it.
I guess that activate and select are two different things.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Filling Column with Numbers

You said "If you don't want to SELECT."
then you should ACTIVATE????

"Bradley Dawson" wrote in message
...
Activate and Select are very similar. As far as moving the activecell,
they're the same.

"Don Guillett" wrote in message
...
If you like it that way, I love it.
I guess that activate and select are two different things.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Filling Column with Numbers

It doesn't have to be tedious.

in the name box enter A3:A3000
hit enter
in the formula bar
=IF(B3="","",IF(B2="",A1+1,A2))
Ctrl+enter

done.

Yes, you do have to know what the last line of the data is.

--
Regards,
Tom Ogilvy

Bradley Dawson wrote in message
...
Your solution is great! I'm just saying that with a large list that
contains blank rows, selecting it can be almost as tedious as a fill.
Especially with some of the lists I deal with. (26K to 30K rows). So in
this code either a department number is placed next to the list or the
department number is incremented depending on if the entry is blank or

not.
Then the activecell moves down one. When it gets to two blank rows it
stops. I suppose going back to the top of the list after it completes

would
have been a nice touch, though.

Anyway, it worked fine when I tested it.

Questions?

"Don Guillett" wrote in message
...
If you don't want to select or fill 3000 names, try this
ActiveCell.Offset(1, 0).Activate

???
======
"Bradley Dawson" wrote in message
...
If you don't want to select or fill 3000 names, try this:

Sub dptnum()
Dim i%
i = 1
Do While Not (IsEmpty(ActiveCell) And IsEmpty(ActiveCell.Offset(1,

0)))
If Not IsEmpty(ActiveCell) Then
ActiveCell.Offset(0, -1) = i
Else
i = i + 1
End If
ActiveCell.Offset(1, 0).Activate
Loop
End Sub





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
Autofiltering then filling down numbers. XLFanatico Excel Discussion (Misc queries) 5 March 13th 09 02:12 AM
Auto filling a table of numbers Rod Excel Worksheet Functions 3 October 30th 08 03:49 PM
Filling Sheet numbers in a column mikresources Excel Worksheet Functions 4 September 24th 07 04:10 AM
Filling Column with Numbers Tom Ogilvy Excel Programming 2 August 31st 03 06:51 PM
Filling Column with Numbers Don Guillett[_4_] Excel Programming 0 August 31st 03 05:43 PM


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