Jump to content

Making a function macro from a sub macro

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
vbprogrammer

vbprogrammer

    Newbie

  • Members
  • Pip
  • 2 posts
I\'ve made a sub macro, but I want to make a function macro out of it instead, so I can use it directly in the sheet in Excel.
Any of you able to point me in the right direction? I know that I can use sum functions that are already in excel, but I want to know how i can do it myself :)

Here is my code:
Sub test()

    Dim Startcell, row, column
    Dim sumnumbers
    

    Set Startcell = Range("Startcell")
    row = Startcell.row
    column = Startcell.column
    sumnumbers = 0
    
    
    Do While Cells(row, column).Value <> ""
    
    
        sumnumbers = sumnumbers + Cells(row, column).Value
             
        row = row + 1
        
    Loop
    
    Range("sum").Value = sumnumbers


End Sub
Here is how it looks like in Excel: ttp://img29.imageshack.us/img29/5290/excel.png

Edited by Orjan, 05 December 2009 - 06:33 AM.
Please use code tags when posting code


#2
vbprogrammer

vbprogrammer

    Newbie

  • Members
  • Pip
  • 2 posts
For some reason when I post it keeps adding \"\\\" in places where it shouldnt be

#3
anglina

anglina

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts

vbprogrammer said:

For some reason when I post it keeps adding \"\\\" in places where it shouldnt be

Try putting the code in these blocks:

Code would Go here


You have to hit the sharp button "#"


and it won't apply any kind of formatting 



That is if you are meaning that when you post to the forums that it applies the extra \\\