Macro help

N

New user

Do anyone know if i want to set a macro which i want to comprise 2 elements:

1: total underline
2: sum ("Sum" function in Excel which automatically sum up all the cells
with figures)

Every time i set, the no. of cells to be added are fixed. for example, Col A
has 3 cells to sum up; when i apply it to Col B which has 5 cells, it also
only add up the last 3 cells, not 5.

Can anyone advise me on this matter?

Thank you so much.
 
S

ShaneDevenshire

Hi,

How is your macro supposed to know how far up to go? Do all the cells need
values or do you some from the current cell to row 1 or column A as the case
may be?
 
A

Argy - Arcasoft

HI Shane!
I think that you are half way to achive what you want in a fairly complete
manner. The reason why this will not work is because when you have the
Template open, and you save it as the new file, the fact is that you still
have the same file, just with a new name. So, you don't have the other file
any more. Two choices here, either you continue this road and then save the
file, close the file and open the template again, or what I am posting here.
As you will see, this is a little more structured, but with a huge
advantage, you don't have to be worry where the file is going to be save, or
pull as once is open, the program will always know where the file was
originally open, so it will know where to save it. Unless otherwise, this is
a good and stable manner to handle this kind of projects. Ok, please copy the
following and substitute your current macro. Let me know how does it work.

Suggestion: Copy the instruction (line) below, in the "This Workbook" part,
wherethe macros and modules are, but in the side of the sheets. This will
guarantee, that even if the program crash, anywhere, as soon you click the
mouse, it will pick up all the public variables. Here is the line

Location_Identification
Argy!

=================== Program ======================

Public Actual_Book As String
Public Actual_Path As String
Public Location As String
Public Location_1 As String
Public Name As String

Function Saving()
' Macro recorded 3/3/2002 by Argemiro Calderon
Location_Identification

Windows(Actual_Book).Activate
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=Location
ActiveWorkbook.SaveAs Filename:=Location_1
Application.DisplayAlerts = True
Windows(Actual_Book).Activate
End Function
Function Location_Identification()
Actual_Book = ActiveWorkbook.Name
Actual_Path = ActiveWorkbook.Path
Location = Actual_Path & "\" & Name
Location_1 = Actual_Path & "\" & Actual_Book
End Function
Sub PrintAndClear()
' PrintAndClear Macro
' Macro recorded 9/10/2008 by me
' Keyboard Shortcut: Ctrl+Shift+Q
Actual_Book = ActiveWorkbook.Name

response = MsgBox("Do you want to Save this to a new file?", vbYesNo,
"Save As")
If response = 6 Then
Name = InputBox("Enter a Filename", "Get Filename")
If Name = "" Then
MsgBox ("The name of the file is in blank. Please check and
hit ok to continue")
End
End If
Saving
' ActiveWorkbook.SaveAs Filename:="c:\" & Name & ".xls"
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True '"I think
this line is not needed"
Workbooks.Open Filename:="P:\Calculations Sheet-2008 WSO.xls"
Range("E6").Select
End Sub
 
A

Argy - Arcasoft

Hi New User:
Please disregard my previous message. That was for somebody else that has
the same subject as yours, so I got confuse. For this case, I think that you
are using a tool, macros, in an ineficient way. If it is to consolidate
numbers that might vary in the lenght depending on the column, probably you
don't need macros. What you need is Pivot Tables. Best regards

Argy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top