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

I am trying to copy one row with formula in it(C7:AI7), to the rows below it,
the number of rows to be copied down the sheet depends on the number of
filled cells in col B (max B7:B67). I.e. If there are four filled cells in
col B (7-11) then I want the range C7:AI7 to be copied down to match. Now
desperate. Anyone help please ?

Thanks in hope

Sybs

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default loop problems

Sub FillFormulas()
Dim rng As Range
Set rng = Range("B7", _
Cells(7, "B").End(xldown))
rng.Offset(0, 1).Resize(, 33).FillDown
End Sub

--
Regards,
Tom Ogilvy

"SYBS" wrote:

I am trying to copy one row with formula in it(C7:AI7), to the rows below it,
the number of rows to be copied down the sheet depends on the number of
filled cells in col B (max B7:B67). I.e. If there are four filled cells in
col B (7-11) then I want the range C7:AI7 to be copied down to match. Now
desperate. Anyone help please ?

Thanks in hope

Sybs

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default loop problems

Hi Tom,

That works for me !!
I di try offset but thought it needed to be in a loop. Can you please
explain how the Resize(, 33).FillDown works and what is the significance
of the '33'.

For future reference, could I put the offset bit into a For each loop if
needed or is the offset more efficient.

Last question. If I want to put a name from a list into every other 6th cell
in a column, how do I phrase that ?

Thanks again, really appreciated

Sybs

"Tom Ogilvy" wrote:

Sub FillFormulas()
Dim rng As Range
Set rng = Range("B7", _
Cells(7, "B").End(xldown))
rng.Offset(0, 1).Resize(, 33).FillDown
End Sub

--
Regards,
Tom Ogilvy

"SYBS" wrote:

I am trying to copy one row with formula in it(C7:AI7), to the rows below it,
the number of rows to be copied down the sheet depends on the number of
filled cells in col B (max B7:B67). I.e. If there are four filled cells in
col B (7-11) then I want the range C7:AI7 to be copied down to match. Now
desperate. Anyone help please ?

Thanks in hope

Sybs

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default loop problems

There are 33 columns in the range C:AI, so the 33 extends the range to
include these columns.

There is no reason to loop for the problem described unless you want the
code to run slower and be more inefficient.

What does every other 6th cell mean? Do you mean every 12th cell?

--
Regards,
Tom Ogilvy


"SYBS" wrote:

Hi Tom,

That works for me !!
I di try offset but thought it needed to be in a loop. Can you please
explain how the Resize(, 33).FillDown works and what is the significance
of the '33'.

For future reference, could I put the offset bit into a For each loop if
needed or is the offset more efficient.

Last question. If I want to put a name from a list into every other 6th cell
in a column, how do I phrase that ?

Thanks again, really appreciated

Sybs

"Tom Ogilvy" wrote:

Sub FillFormulas()
Dim rng As Range
Set rng = Range("B7", _
Cells(7, "B").End(xldown))
rng.Offset(0, 1).Resize(, 33).FillDown
End Sub

--
Regards,
Tom Ogilvy

"SYBS" wrote:

I am trying to copy one row with formula in it(C7:AI7), to the rows below it,
the number of rows to be copied down the sheet depends on the number of
filled cells in col B (max B7:B67). I.e. If there are four filled cells in
col B (7-11) then I want the range C7:AI7 to be copied down to match. Now
desperate. Anyone help please ?

Thanks in hope

Sybs

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default loop problems

Thanks for that, so I could use that number to represent different column
ranges, that will make a difference.

The 6/12th row explanation is. From my list of names on Sheet 1 I am
populating col B on 5 other sheets, 1 row to a name, but two other sheets use
6 rows per name, so the 1st name would be on the 13th line, 2nd name on 20th
line etc. At the moment I have simply coded the On activate for the list to
be copied and pasted to the other pages (where they take up one row). So I
am looking to put the names on the other sheets in Col B13/b20/b27 etc.

"Tom Ogilvy" wrote:

There are 33 columns in the range C:AI, so the 33 extends the range to
include these columns.

There is no reason to loop for the problem described unless you want the
code to run slower and be more inefficient.

What does every other 6th cell mean? Do you mean every 12th cell?

--
Regards,
Tom Ogilvy


"SYBS" wrote:

Hi Tom,

That works for me !!
I di try offset but thought it needed to be in a loop. Can you please
explain how the Resize(, 33).FillDown works and what is the significance
of the '33'.

For future reference, could I put the offset bit into a For each loop if
needed or is the offset more efficient.

Last question. If I want to put a name from a list into every other 6th cell
in a column, how do I phrase that ?

Thanks again, really appreciated

Sybs

"Tom Ogilvy" wrote:

Sub FillFormulas()
Dim rng As Range
Set rng = Range("B7", _
Cells(7, "B").End(xldown))
rng.Offset(0, 1).Resize(, 33).FillDown
End Sub

--
Regards,
Tom Ogilvy

"SYBS" wrote:

I am trying to copy one row with formula in it(C7:AI7), to the rows below it,
the number of rows to be copied down the sheet depends on the number of
filled cells in col B (max B7:B67). I.e. If there are four filled cells in
col B (7-11) then I want the range C7:AI7 to be copied down to match. Now
desperate. Anyone help please ?

Thanks in hope

Sybs



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default loop problems

Dim list as Range, cell as range
Dim rw as long
rw = 13
set list = Worksheets("Sheet1").Range("B1:B20")
for each cell in list
worksheets("Sheet2").Cells(rw,"B").Value = cell.value
rw = rw + 7
Next

--
Regards,
Tom Ogilvy


"SYBS" wrote:

Thanks for that, so I could use that number to represent different column
ranges, that will make a difference.

The 6/12th row explanation is. From my list of names on Sheet 1 I am
populating col B on 5 other sheets, 1 row to a name, but two other sheets use
6 rows per name, so the 1st name would be on the 13th line, 2nd name on 20th
line etc. At the moment I have simply coded the On activate for the list to
be copied and pasted to the other pages (where they take up one row). So I
am looking to put the names on the other sheets in Col B13/b20/b27 etc.

"Tom Ogilvy" wrote:

There are 33 columns in the range C:AI, so the 33 extends the range to
include these columns.

There is no reason to loop for the problem described unless you want the
code to run slower and be more inefficient.

What does every other 6th cell mean? Do you mean every 12th cell?

--
Regards,
Tom Ogilvy


"SYBS" wrote:

Hi Tom,

That works for me !!
I di try offset but thought it needed to be in a loop. Can you please
explain how the Resize(, 33).FillDown works and what is the significance
of the '33'.

For future reference, could I put the offset bit into a For each loop if
needed or is the offset more efficient.

Last question. If I want to put a name from a list into every other 6th cell
in a column, how do I phrase that ?

Thanks again, really appreciated

Sybs

"Tom Ogilvy" wrote:

Sub FillFormulas()
Dim rng As Range
Set rng = Range("B7", _
Cells(7, "B").End(xldown))
rng.Offset(0, 1).Resize(, 33).FillDown
End Sub

--
Regards,
Tom Ogilvy

"SYBS" wrote:

I am trying to copy one row with formula in it(C7:AI7), to the rows below it,
the number of rows to be copied down the sheet depends on the number of
filled cells in col B (max B7:B67). I.e. If there are four filled cells in
col B (7-11) then I want the range C7:AI7 to be copied down to match. Now
desperate. Anyone help please ?

Thanks in hope

Sybs

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default loop problems

Thank you for that help. I am working on both areas and will let you know
how it goes.

Sybs


"Tom Ogilvy" wrote:

Dim list as Range, cell as range
Dim rw as long
rw = 13
set list = Worksheets("Sheet1").Range("B1:B20")
for each cell in list
worksheets("Sheet2").Cells(rw,"B").Value = cell.value
rw = rw + 7
Next

--
Regards,
Tom Ogilvy


"SYBS" wrote:

Thanks for that, so I could use that number to represent different column
ranges, that will make a difference.

The 6/12th row explanation is. From my list of names on Sheet 1 I am
populating col B on 5 other sheets, 1 row to a name, but two other sheets use
6 rows per name, so the 1st name would be on the 13th line, 2nd name on 20th
line etc. At the moment I have simply coded the On activate for the list to
be copied and pasted to the other pages (where they take up one row). So I
am looking to put the names on the other sheets in Col B13/b20/b27 etc.

"Tom Ogilvy" wrote:

There are 33 columns in the range C:AI, so the 33 extends the range to
include these columns.

There is no reason to loop for the problem described unless you want the
code to run slower and be more inefficient.

What does every other 6th cell mean? Do you mean every 12th cell?

--
Regards,
Tom Ogilvy


"SYBS" wrote:

Hi Tom,

That works for me !!
I di try offset but thought it needed to be in a loop. Can you please
explain how the Resize(, 33).FillDown works and what is the significance
of the '33'.

For future reference, could I put the offset bit into a For each loop if
needed or is the offset more efficient.

Last question. If I want to put a name from a list into every other 6th cell
in a column, how do I phrase that ?

Thanks again, really appreciated

Sybs

"Tom Ogilvy" wrote:

Sub FillFormulas()
Dim rng As Range
Set rng = Range("B7", _
Cells(7, "B").End(xldown))
rng.Offset(0, 1).Resize(, 33).FillDown
End Sub

--
Regards,
Tom Ogilvy

"SYBS" wrote:

I am trying to copy one row with formula in it(C7:AI7), to the rows below it,
the number of rows to be copied down the sheet depends on the number of
filled cells in col B (max B7:B67). I.e. If there are four filled cells in
col B (7-11) then I want the range C7:AI7 to be copied down to match. Now
desperate. Anyone help please ?

Thanks in hope

Sybs

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
Macro Help - Loop Problems ksp Excel Programming 2 May 1st 06 03:02 AM
problems with loop Arjan Excel Programming 1 December 8th 05 09:10 AM
So close! Problems with Loop Linking to specific cells in pivot table Excel Programming 3 February 7th 05 05:28 PM
for next loop problems cliee Excel Programming 3 November 1st 04 12:05 PM
Loop code problems pauluk[_51_] Excel Programming 2 April 23rd 04 10:30 AM


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