Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Need help to have macro populate a column with formula to end of     column.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
S Himmelrich - 22 Jan 2008 19:17 GMT
My formula that should populate column K is: =SUM(J1/MACRO!G11), which
takes the value in the same row (column J) and divides into a
refereced cell, which will stay the same always.  The macro should
evaluate until the end of the column.
Susan - 22 Jan 2008 19:24 GMT
how does the program decide where the end of the column is?
susan

> My formula that should populate column K is: =SUM(J1/MACRO!G11), which
> takes the value in the same row (column J) and divides into a
> refereced cell, which will stay the same always.  The macro should
> evaluate until the end of the column.
GTVT06 - 22 Jan 2008 19:30 GMT
> My formula that should populate column K is: =SUM(J1/MACRO!G11), which
> takes the value in the same row (column J) and divides into a
> refereced cell, which will stay the same always.  The macro should
> evaluate until the end of the column.

Not sure I fully understood your message, but I think your looking for
a macro that will fill down the formula in Column K until it matches
the lenght of Column J? If so try this:

Sub filldown()
   Dim rng As Range
'    'Fill Formula down formula in K until last J with data
   Set rng = Range(Cells(1, "J"), Cells(Rows.Count, "J").End(xlUp))
   rng.Offset(0, 1).Formula = "=SUM(J1/MACRO!$G$11)"
End Sub
S Himmelrich - 22 Jan 2008 19:35 GMT
Here is what I'm looking for, however I get an error on the row I've
designated as an error:

   Dim last7 As Long
   last7 = Worksheets("Working Sheet").Cells(Rows.Count,
"D").End(xlUp).Row
   Range("K1").Formula = "=IF(RC[1]="","",SUM(RC[1]/MACRO!$G$11))"
   Range("K1").AutoFill Destination:=Range("K1:K" & last7)  <---ERROR
HERE
GTVT06 - 22 Jan 2008 19:47 GMT
> Here is what I'm looking for, however I get an error on the row I've
> designated as an error:
[quoted text clipped - 5 lines]
>     Range("K1").AutoFill Destination:=Range("K1:K" & last7)  <---ERROR
> HERE

Try mine but Substitue J for D, try this:

Sub filldown()
   Dim rng As Range
'    'Fill Formula in K dowun until last D with data
   Set rng = Range(Cells(1, "D"), Cells(Rows.Count, "D").End(xlUp))
   rng.Offset(0, 7).Formula = "=IF(J1="""","""",SUM(J1/MACRO!$G
$11))"
End Sub
Dave Peterson - 22 Jan 2008 20:06 GMT
Check your first thread.

> My formula that should populate column K is: =SUM(J1/MACRO!G11), which
> takes the value in the same row (column J) and divides into a
> refereced cell, which will stay the same always.  The macro should
> evaluate until the end of the column.

Signature

Dave Peterson

S Himmelrich - 22 Jan 2008 20:48 GMT
Solution:

 Dim rng As Range
   Set rng = Range(Cells(1, "D"), Cells(Rows.Count, "D").End(xlUp))
   rng.Offset(0, 7).Formula = "=IF(J1="""","""",SUM(J1/MACRO!$G$11))"
Dave Peterson - 22 Jan 2008 22:12 GMT
You have a response to this similar post at the original thread.

> Solution:
>
>   Dim rng As Range
>     Set rng = Range(Cells(1, "D"), Cells(Rows.Count, "D").End(xlUp))
>     rng.Offset(0, 7).Formula = "=IF(J1="""","""",SUM(J1/MACRO!$G$11))"

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.