PC Review


Reply
Thread Tools Rate Thread

Beginner - Loop

 
 
ra
Guest
Posts: n/a
 
      10th Sep 2007
Hello,

I have a data set that contains formulas.
Due to the large size the formulas are only kept in the first row and
only copied down when report is updated monthly - these cells are then
hardcoded.

I cant copy formula down the whole way so need a loop to do copy
formula, calculate result and then hardcode before moving down to the
next row, each time taking the formula from row one.

Can anyone get me started on this?

thanks

 
Reply With Quote
 
 
 
 
Zone
Guest
Posts: n/a
 
      10th Sep 2007
Say your formulas are in cells D1 through H1. You want them copied in the
same columns in rows 2 through 50, and then replace the formulas with their
values. Copy this code and paste it in a standard module. Should get you
started. HTH, James

Sub Test()
Dim k As Long
For k = 2 To 50
Range("d1:h1").Copy _
Destination:=Cells(k, "d")
Range(Cells(k, "d"), Cells(k, "h")).Formula _
= Range(Cells(k, "d"), Cells(k, "h")).Value
Next k
End Sub

"ra" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a data set that contains formulas.
> Due to the large size the formulas are only kept in the first row and
> only copied down when report is updated monthly - these cells are then
> hardcoded.
>
> I cant copy formula down the whole way so need a loop to do copy
> formula, calculate result and then hardcode before moving down to the
> next row, each time taking the formula from row one.
>
> Can anyone get me started on this?
>
> thanks
>



 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      10th Sep 2007
If you can determine the extent of the rows by checking column 1 and the
formulas are in B1:M1 (as an example)

then this doesn't require any looping:

Sub copydown()
Dim lrow As Long
Dim r As Range, r1 As Range
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Set r = Range("B1:M1").Resize(lrow, 12)
Range("B1:M1").AutoFill r
Set r1 = r.Offset(1, 0).Resize(lrow - 1, 12)
r1.Copy
r1.PasteSpecial xlValues
End Sub

--
Regards,
Tom Ogilvy



"ra" wrote:

> Hello,
>
> I have a data set that contains formulas.
> Due to the large size the formulas are only kept in the first row and
> only copied down when report is updated monthly - these cells are then
> hardcoded.
>
> I cant copy formula down the whole way so need a loop to do copy
> formula, calculate result and then hardcode before moving down to the
> next row, each time taking the formula from row one.
>
> Can anyone get me started on this?
>
> thanks
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Simple window application with a loop and a button to eventuallystop the loop Joe Cool Microsoft C# .NET 15 29th Jul 2009 08:40 PM
returning back to loop check condition without completing the loop ashish128 Microsoft Excel Programming 13 3rd Apr 2008 12:53 PM
No Class at ALL!!! beginner/beginner question =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?= Microsoft ASP .NET 7 3rd Feb 2005 02:47 PM
Convert loop with Match function to avoid nested loop??? Kobayashi Microsoft Excel Programming 2 17th Mar 2004 06:36 PM
Beginner: Window Not Responding While Continuous Loop Executes Shamrokk Microsoft C# .NET 8 10th Sep 2003 05:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:05 AM.