View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
bodhisatvaofboogie bodhisatvaofboogie is offline
external usenet poster
 
Posts: 93
Default Macro Formula Reproduction

It's all workin....SMOOTH!!! THANKS!!!!!!

"Dave Peterson" wrote:

maybe...

LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Cells(LastRow + 2, "D") = Application.Sum _
(Range(Cells(1, "D"), Cells(LastRow, "D")))
range("e2:E" & lastrow).formula = "=d2/d$" & lastrow

I'm not sure I understand, though.




bodhisatvaofboogie wrote:

That works great Dave, NOW the only thing is:

The Row 51 in the formula, that will be in differing spots from data to
data. That is a subtotal that is placed in the last row +2 using this
formula:

LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Cells(LastRow + 2, "D") = Application.Sum _
(Range(Cells(1, "D"), Cells(LastRow, "D")))

So the entire column is then subtotaled into an empty cell located in a cell
two cells below the last row cell. So how do I combine the two things, so
that the 51 in the formula you provided for me will in fact be the lastrow +2
space. That way when I import varying data sets, it's not stuck at row 51
for the subtotal. Make sense???

THANKS!!!

"Dave Peterson" wrote:

You really don't want the whole column--from E2:E65536, do you?

Can you pick out a column that will indicate where you want to stop.

I used column A in this sample:

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("e2:E" & lastrow).formula = "=d2/d$51"
'or
.range("e2:e" & lastrow).formular1c1 = "=rc4/rc51c4"
end with



bodhisatvaofboogie wrote:

Here is what I am using:

Range("E2").Select
ActiveCell.FormulaR1C1 = "=RC4/R51C4"
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E49")

That selects E2, applies the formula and autofills down to the last cell
with values in it which happens to be row 49. NOW, how do I code it to do
that regardless of how many rows are in the imported data. Because some data
will be 60 rows long, others will be 50, etc. That formula selects
specifically that amount and I want it to just select the whole column
regardless of amount of rows. Make sense?

So I'm assuming some kind of change to:

Selection.AutoFill Destination:=Range("E2:E49")

or am I way off???

THANKS!!!

--

Dave Peterson


--

Dave Peterson