Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default AutoFill Loop

HI all, I am still pretty new at this VBA stuff. I have a need to select a
formula in a spreadsheet and fill it down to the last cell possible, then
offset over the the right 9 cell and Autofill again, offsett 9 cells and
repeat until it can't find a activecell with info in it.

The problem is the cells I am Autofilling are all different amounts of fill
some are 600 rows and some are 6000.

Please help if possible.
--
Pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default AutoFill Loop

Using example locations:
set rng = Range(cells(2,"B"),cells(rows.count,"B").End(xlup) )

gives you a reference to the filled cells. then if you wanted to fill
column C

rng.offset(0,1).Formula = rng.offset(0,1).Resize(1,1).Formula

or for autofill possibly

rng.offset(0,1).Resize(1,1).Autofill Destination:=rng.offset(0,1)

--
Regards,
Tom Ogilvy



"Pete" wrote in message
...
HI all, I am still pretty new at this VBA stuff. I have a need to select a
formula in a spreadsheet and fill it down to the last cell possible, then
offset over the the right 9 cell and Autofill again, offsett 9 cells and
repeat until it can't find a activecell with info in it.

The problem is the cells I am Autofilling are all different amounts of

fill
some are 600 rows and some are 6000.

Please help if possible.
--
Pete



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default AutoFill Loop

Tom

Thanks for your help, but I am not following your code.

Here is what I got so far
Sub PB_Get_Nums()
ActiveCell.Offset(1, 5).Range("A1").Select
Range("F2").End(xlDown).Offset(0, 1).FillDown
Do
With ActiveCell
ActiveCell.Offset(0, 9).Range("A1").Select


`Need autofill code here to fill down to last cell.


End With
Loop Until IsEmpty(ActiveCell.Value)
End Sub

I could simply tell it to select the next cell in my sheet ("O2") but I have
roughly 45 of these to do in 8 different workbooks and want to loop through
it to save time. I know it's probably an easy fix, but I am not seeing it.
--
Pete


"Tom Ogilvy" wrote:

Using example locations:
set rng = Range(cells(2,"B"),cells(rows.count,"B").End(xlup) )

gives you a reference to the filled cells. then if you wanted to fill
column C

rng.offset(0,1).Formula = rng.offset(0,1).Resize(1,1).Formula

or for autofill possibly

rng.offset(0,1).Resize(1,1).Autofill Destination:=rng.offset(0,1)

--
Regards,
Tom Ogilvy



"Pete" wrote in message
...
HI all, I am still pretty new at this VBA stuff. I have a need to select a
formula in a spreadsheet and fill it down to the last cell possible, then
offset over the the right 9 cell and Autofill again, offsett 9 cells and
repeat until it can't find a activecell with info in it.

The problem is the cells I am Autofilling are all different amounts of

fill
some are 600 rows and some are 6000.

Please help if possible.
--
Pete




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default AutoFill Loop

Sub PB_Get_Nums()
Range("F2").Select
Do
With ActiveCell
.End(xlDown).Offset(0, 1).FillDown

.Offset(0, 9).Select

End With
Loop Until IsEmpty(ActiveCell.Value)
End Sub

--
Regards,
Tom Ogilvy


"Pete" wrote in message
...
Tom

Thanks for your help, but I am not following your code.

Here is what I got so far
Sub PB_Get_Nums()
ActiveCell.Offset(1, 5).Range("A1").Select
Range("F2").End(xlDown).Offset(0, 1).FillDown
Do
With ActiveCell
ActiveCell.Offset(0, 9).Range("A1").Select


`Need autofill code here to fill down to last cell.


End With
Loop Until IsEmpty(ActiveCell.Value)
End Sub

I could simply tell it to select the next cell in my sheet ("O2") but I

have
roughly 45 of these to do in 8 different workbooks and want to loop

through
it to save time. I know it's probably an easy fix, but I am not seeing it.
--
Pete


"Tom Ogilvy" wrote:

Using example locations:
set rng = Range(cells(2,"B"),cells(rows.count,"B").End(xlup) )

gives you a reference to the filled cells. then if you wanted to fill
column C

rng.offset(0,1).Formula = rng.offset(0,1).Resize(1,1).Formula

or for autofill possibly

rng.offset(0,1).Resize(1,1).Autofill Destination:=rng.offset(0,1)

--
Regards,
Tom Ogilvy



"Pete" wrote in message
...
HI all, I am still pretty new at this VBA stuff. I have a need to

select a
formula in a spreadsheet and fill it down to the last cell possible,

then
offset over the the right 9 cell and Autofill again, offsett 9 cells

and
repeat until it can't find a activecell with info in it.

The problem is the cells I am Autofilling are all different amounts of

fill
some are 600 rows and some are 6000.

Please help if possible.
--
Pete






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default AutoFill Loop

Tom, I'm sorry to such a pest, but your code does not work properly. I can
follow you logic on the loop and the code does loop properly, however it does
not fill down the formula on the selected cell during the loop.
--
Pete


"Tom Ogilvy" wrote:

Sub PB_Get_Nums()
Range("F2").Select
Do
With ActiveCell
.End(xlDown).Offset(0, 1).FillDown

.Offset(0, 9).Select

End With
Loop Until IsEmpty(ActiveCell.Value)
End Sub

--
Regards,
Tom Ogilvy


"Pete" wrote in message
...
Tom

Thanks for your help, but I am not following your code.

Here is what I got so far
Sub PB_Get_Nums()
ActiveCell.Offset(1, 5).Range("A1").Select
Range("F2").End(xlDown).Offset(0, 1).FillDown
Do
With ActiveCell
ActiveCell.Offset(0, 9).Range("A1").Select


`Need autofill code here to fill down to last cell.


End With
Loop Until IsEmpty(ActiveCell.Value)
End Sub

I could simply tell it to select the next cell in my sheet ("O2") but I

have
roughly 45 of these to do in 8 different workbooks and want to loop

through
it to save time. I know it's probably an easy fix, but I am not seeing it.
--
Pete


"Tom Ogilvy" wrote:

Using example locations:
set rng = Range(cells(2,"B"),cells(rows.count,"B").End(xlup) )

gives you a reference to the filled cells. then if you wanted to fill
column C

rng.offset(0,1).Formula = rng.offset(0,1).Resize(1,1).Formula

or for autofill possibly

rng.offset(0,1).Resize(1,1).Autofill Destination:=rng.offset(0,1)

--
Regards,
Tom Ogilvy



"Pete" wrote in message
...
HI all, I am still pretty new at this VBA stuff. I have a need to

select a
formula in a spreadsheet and fill it down to the last cell possible,

then
offset over the the right 9 cell and Autofill again, offsett 9 cells

and
repeat until it can't find a activecell with info in it.

The problem is the cells I am Autofilling are all different amounts of
fill
some are 600 rows and some are 6000.

Please help if possible.
--
Pete








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default AutoFill Loop

You, of course, hold the distinct advantage of being able to look at the
sheet, so based on your statement, I can only imagine that column F is the
definitive column for determining the extent of fill. If so


Sub PB_Get_Nums()
set rng = Range(Range("F2"),Range("F2).End(xldown))
for i = 0 to 27
if isempty(rng(1).offset(0,i*9)) then exit sub
rng.offset(0,i*9).Filldown
Next
End Sub

If not, change F2 to the correct cell.

--
Regards,
Tom Ogilvy



"Pete" wrote in message
...
Tom, I'm sorry to such a pest, but your code does not work properly. I can
follow you logic on the loop and the code does loop properly, however it

does
not fill down the formula on the selected cell during the loop.
--
Pete


"Tom Ogilvy" wrote:

Sub PB_Get_Nums()
Range("F2").Select
Do
With ActiveCell
.End(xlDown).Offset(0, 1).FillDown

.Offset(0, 9).Select

End With
Loop Until IsEmpty(ActiveCell.Value)
End Sub

--
Regards,
Tom Ogilvy


"Pete" wrote in message
...
Tom

Thanks for your help, but I am not following your code.

Here is what I got so far
Sub PB_Get_Nums()
ActiveCell.Offset(1, 5).Range("A1").Select
Range("F2").End(xlDown).Offset(0, 1).FillDown
Do
With ActiveCell
ActiveCell.Offset(0, 9).Range("A1").Select


`Need autofill code here to fill down to last cell.


End With
Loop Until IsEmpty(ActiveCell.Value)
End Sub

I could simply tell it to select the next cell in my sheet ("O2") but

I
have
roughly 45 of these to do in 8 different workbooks and want to loop

through
it to save time. I know it's probably an easy fix, but I am not seeing

it.
--
Pete


"Tom Ogilvy" wrote:

Using example locations:
set rng = Range(cells(2,"B"),cells(rows.count,"B").End(xlup) )

gives you a reference to the filled cells. then if you wanted to

fill
column C

rng.offset(0,1).Formula = rng.offset(0,1).Resize(1,1).Formula

or for autofill possibly

rng.offset(0,1).Resize(1,1).Autofill Destination:=rng.offset(0,1)

--
Regards,
Tom Ogilvy



"Pete" wrote in message
...
HI all, I am still pretty new at this VBA stuff. I have a need to

select a
formula in a spreadsheet and fill it down to the last cell

possible,
then
offset over the the right 9 cell and Autofill again, offsett 9

cells
and
repeat until it can't find a activecell with info in it.

The problem is the cells I am Autofilling are all different

amounts of
fill
some are 600 rows and some are 6000.

Please help if possible.
--
Pete








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
Loop and autofill CaroleO Excel Discussion (Misc queries) 1 April 12th 07 05:37 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Q. Autofill question: Can I autofill alpha characters like I can numbers? George[_22_] Excel Programming 5 August 7th 04 10:33 AM


All times are GMT +1. The time now is 02:30 PM.

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"