Automatic Block

sylbalm

New Member
Joined
Aug 17, 2007
Messages
5
Office Version
  1. 365
Platform
  1. MacOS
I'm fairly new to Excel and am working on a cabinetry estimating spreadsheet. I want to automatically create a block of cells with the totals of everything two or three rows below everything I've entered. Sometimes the spreadsheet will be 20 rows, sometimes 50. I've made a group of cells that add everything up, add tax, subtract discounts, etc. and I want it to always be a couple of rows below the last thing I've entered without constantly having to cut and paste or add rows. Is this possible?

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi
Paste the following codes in the macro window ( Alt F11)
sub total()
Code:
x= cells(rows.count,1).end(xlUp).row
y = cells(1,columns.count).end(xltoleft).column
for a = 1 to y
b = chr(a+64)
c = b & "1:" & b & x
cells(x+3,a) = "=sum(" & c & ")
next a
end sub
run the macro. It will total each column 3 rows below the last row.
Ravi
 
Upvote 0
ravishankar:

That will fail at Column AA, but there is no need for a loop:

sylbalm:

Perhaps:

Code:
Sub test2()
Dim x As Long, y As Long
x = Cells(Rows.Count, 1).End(xlUp).Row + 3
y = Cells(1, Columns.Count).End(xlToLeft).Column
Range(Cells(x, 1), Cells(x, y)).Formula = "=SUM(A1:A" & x - 3 & ")"
End Sub
 
Upvote 0
Hi
Thanks hotpepper.
I am aware that it works from a to z only. I have written codes to cope up with columns upto IV . I thought unless the board member specifies the no. of columns, i could use a single alphabet. also I have noted the improvement you have done in avoiding the loop to copy the data.
Ravi
 
Upvote 0

Forum statistics

Threads
1,214,894
Messages
6,122,124
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top