#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Sub Sum


Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2 starting
in B2 and ending in AA2 to put the formulas below inside. If you can help I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Sub Sum


Buddy,
Try:

Range("B2:AA2").Select
Selection.FillRight

This will do the same as Ctrl+R from the keyboard
--
Chris Freeman
IT Project Coordinator


"Buddy" wrote:

Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2 starting
in B2 and ending in AA2 to put the formulas below inside. If you can help I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sub Sum


In B3 I am want to put this formula =SUM(B3:B15)


That'd give you a circular reference, I guess you mean you want the formula
in B2 etc

Range("B2:AA2").Formula = "=SUM(B3:B15)"

Regards,
Peter T


"Buddy" wrote in message
...
Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2
starting
in B2 and ending in AA2 to put the formulas below inside. If you can help
I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sub Sum


Sub Sum()


LastRow = Range("A" & Rows.Count).End(xlUp).Row
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Range("A" & (LastRow + 2)) = "Total"
Range("B" & (LastRow + 2)).Formula = _
"=SUM(B2:B" & LastRow & ")"

Range("B" & (LastRow + 2)).Copy _
Destination:=Range(Range("B" & (LastRow + 2)), Cells((LastRow + 2),
LastColumn))


End Sub




"Buddy" wrote:

Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2 starting
in B2 and ending in AA2 to put the formulas below inside. If you can help I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Sub Sum


Peter,
Yes, the function would need to start from the first cell that has the
formula, but the fomula would need to be in the cell B2 with with a formula
=Sum(B3:B15)

Then select B2:AA2, and selection.rightfill.
--
Chris Freeman
IT Project Coordinator


"Peter T" wrote:

In B3 I am want to put this formula =SUM(B3:B15)


That'd give you a circular reference, I guess you mean you want the formula
in B2 etc

Range("B2:AA2").Formula = "=SUM(B3:B15)"

Regards,
Peter T


"Buddy" wrote in message
...
Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2
starting
in B2 and ending in AA2 to put the formulas below inside. If you can help
I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Sub Sum


Thank you for the tip. I appreciate your input.

"Peter T" wrote:

In B3 I am want to put this formula =SUM(B3:B15)


That'd give you a circular reference, I guess you mean you want the formula
in B2 etc

Range("B2:AA2").Formula = "=SUM(B3:B15)"

Regards,
Peter T


"Buddy" wrote in message
...
Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2
starting
in B2 and ending in AA2 to put the formulas below inside. If you can help
I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Sub Sum


I am grateful for your input. Thanks for the discussion

"Chris Freeman" wrote:

Peter,
Yes, the function would need to start from the first cell that has the
formula, but the fomula would need to be in the cell B2 with with a formula
=Sum(B3:B15)

Then select B2:AA2, and selection.rightfill.
--
Chris Freeman
IT Project Coordinator


"Peter T" wrote:

In B3 I am want to put this formula =SUM(B3:B15)


That'd give you a circular reference, I guess you mean you want the formula
in B2 etc

Range("B2:AA2").Formula = "=SUM(B3:B15)"

Regards,
Peter T


"Buddy" wrote in message
...
Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2
starting
in B2 and ending in AA2 to put the formulas below inside. If you can help
I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Sub Sum


Remarkable. Thank you very much for your help Sir. I am very thankful for
your direction. It works very well.

"Joel" wrote:

Sub Sum()


LastRow = Range("A" & Rows.Count).End(xlUp).Row
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column

Range("A" & (LastRow + 2)) = "Total"
Range("B" & (LastRow + 2)).Formula = _
"=SUM(B2:B" & LastRow & ")"

Range("B" & (LastRow + 2)).Copy _
Destination:=Range(Range("B" & (LastRow + 2)), Cells((LastRow + 2),
LastColumn))


End Sub




"Buddy" wrote:

Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2 starting
in B2 and ending in AA2 to put the formulas below inside. If you can help I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sub Sum


Chris, couple of points. If you want to use autifill there's no need to use
Select -

Range("B2").Formula = "=Sum(B3:B15)"
Range("B2").AutoFill Range("B2:AA2")

However the way I suggested previously is more efficient and avoids
triggering a change event, simply

Range("B2:AA2").Formula = "=Sum(B3:B15)"

Regards,
Peter T


"Chris Freeman" wrote in message
...
Peter,
Yes, the function would need to start from the first cell that has the
formula, but the fomula would need to be in the cell B2 with with a
formula
=Sum(B3:B15)

Then select B2:AA2, and selection.rightfill.
--
Chris Freeman
IT Project Coordinator


"Peter T" wrote:

In B3 I am want to put this formula =SUM(B3:B15)


That'd give you a circular reference, I guess you mean you want the
formula
in B2 etc

Range("B2:AA2").Formula = "=SUM(B3:B15)"

Regards,
Peter T


"Buddy" wrote in message
...
Sub Sum()
Range("Rows(2)" & Range("B:AA" & Rows.Count).End(xlUp).Row).Formula =
"=SUM(B3:B15)"
End Sub

Here is my current macro. I am aiming to get every Column in Row 2
starting
in B2 and ending in AA2 to put the formulas below inside. If you can
help
I
would appreciate it.

In B3 I am want to put this formula =SUM(B3:B15)
In C3 I am want to put this formula =SUM(C3:C15)
In D3 I am want to put this formula =SUM(D3:D15)
Continued...
In AA3 I am want to put this formula =SUM(AA3:AA15)






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



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