473,513 Members | 2,519 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sum Cells in range above in Excel 2000 VBA

63 New Member
I am trying to write some VBA in Excel 2000 that scans down column L and inserts the Autosum command in each blank cell.

Outside of VBA when I click the autosum command excel sums all the cells above it up to the blank cell above. That is to say that it automatically works out what the range is that I want to sum (and this is fine!)

When I record this as a macro - and go to view the code it specifies the cells that the autosum calculated needed summing - rather than just registering that I had clicked on Autosum

NB I will be applying this macro to data whose ranges will change so this is no use to me!

I simply want the macro to include the code for clicking on Autosum

This is what I have so far:

Columns("L:L").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=SUM(R[-177]C:R[-1]C)"

Is there any way to get the formula to simply equal pressing autosum?
When I put in "=Sum()" it doesn't like it as it seems to need me to specify the range!

HELP!
Aug 22 '07 #1
4 3515
grego9
63 New Member
I've sussed it! - I found the following worked perfectly.

Sub AutoSum()
CommandBars.FindControl(ID:=226).Execute
Application.SendKeys "~"
End Sub

There are a list of other control ID's on the microsoft website
Aug 22 '07 #2
Killer42
8,435 Recognized Expert Expert
... There are a list of other control ID's on the microsoft website
You're too quick for us! :)

Thanks for the info about the control IDs, it sounds potentially quite useful.
Aug 23 '07 #3
grego9
63 New Member
You're too quick for us! :)

Thanks for the info about the control IDs, it sounds potentially quite useful.

The Microsoft Excel 2000 control ID list can be found at http://support.microsoft.com/kb/213552.

I think the numbers might be different for different versions of excel

thanks
Aug 23 '07 #4
ARWien
1 New Member
Hey Greg,

Thanks for the information. I was having the same problem as well and found your post online.

However, I am having a problem with the code. After I run the following code:

Sub Autosum()

CommandBars.FindControl(ID:=226).Execute
Application.SendKeys "~"

End Sub

I cannot get the autosum to stay in the active cell. The code never closes out of the cell but leaves me with the blinking cursor and the ability to edit that cell w/o clicking on it. I have to manually push enter after the macro to keep the autosum and exit out of the active cell.

Also, if at the end of the code, I select another cell (i.e. Range("A1").Select), the autosum does not stay in the cell that I want it in but goes to the cell I select. It is a vicious cycle that I cannot get out of.

Any suggestions?

Thanks.
Jun 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
28413
by: zxo102 | last post by:
Hi there, I need your help for python <--> excel. I want to paste selected cells (range) to different location on the same sheet in Excel through python. I have tried it for a while but could not...
4
8831
by: BerkshireGuy | last post by:
I have the following Access code that exports to Excel, inserts a title, changes the color of the title, and then changes the format of several columns to currency. The following code sometimes...
3
25308
by: Damian Arntzen | last post by:
I'm a beginner to moderate programmer who's fiddling around with automating Excel, in particular after being able to have the user fill out a form and it then generate the workbook. I can't quite...
0
19857
by: Carlos Lozano | last post by:
Hi, I have an application that creates Excel files and I ma having trouble formatting cells. I fill all cells required, sewt fonts and everything, but have a cell that contains multiple text...
2
46466
by: Chris Bellini | last post by:
Greetings! I'm developing a C# application that needs to read some data from a selected XLS file. I've used VB in the past to automate Excel but this is the first time I've used C#. Back in VB,...
1
5832
by: Glen Vermeylen | last post by:
Hi, For a project at school we have to automate the assignment of seats in classrooms to students during the exams. The lady who previously did everything manually kept the layouts of the...
5
3027
by: mrid via DotNetMonster.com | last post by:
hi. im exporting data from a vb form to excel. i am able to create a new excel file, save and edit it without any trouble, but the formatting is giving me hell! i need to be able to show certain...
4
15464
by: ielamrani | last post by:
Hi, I am getting this error when I try to export to an excel sheet. When I click on a button to export the first time it's fine, I rename the exported excel sheet and I try to export it again and I...
0
3501
by: drfish | last post by:
Hi, I'm a complete novice when it comes to VB so need some help. I would like a macro that performs linear regression for different cell ranges each time it is run, depending on the number of...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.