+ Reply to Thread
Results 1 to 6 of 6

functions

  1. #1
    Kanaski79
    Guest

    functions

    Can a Function call a macro? Say during a sort or lookup opperation you want
    some special data that the macro returns?

    Kevin

  2. #2
    Vacation's Over
    Guest

    RE: functions

    If you convert your macro to a function then a function can call another
    function.

    Although there are many exceptions: a macro does something and a function
    returns a value. So a function looking for information would be expected to
    call another function.

    "Kanaski79" wrote:

    > Can a Function call a macro? Say during a sort or lookup opperation you want
    > some special data that the macro returns?
    >
    > Kevin


  3. #3
    Kanaski79
    Guest

    RE: functions

    Don't know if you saw my other post, but it was about finding out how many
    cells a merged cell group occupies. I need that number from the macro that
    someone responded with to use that as the range for the lookup and max
    functions. Do you think that would work?

    this was the macro they gave me.

    Sub test()
    ActiveCell.Value = Format(Date, "dd-mmm-yyyy")
    End Sub

    Thanks

    Kevin

    "Vacation's Over" wrote:

    > If you convert your macro to a function then a function can call another
    > function.
    >
    > Although there are many exceptions: a macro does something and a function
    > returns a value. So a function looking for information would be expected to
    > call another function.
    >
    > "Kanaski79" wrote:
    >
    > > Can a Function call a macro? Say during a sort or lookup opperation you want
    > > some special data that the macro returns?
    > >
    > > Kevin


  4. #4
    Vacation's Over
    Guest

    RE: functions

    User defined functions:
    Create your own function simply by using Function instead of Sub. Then set
    your function = value you require

    Function MergeCount(Cellref as range) as Integer

    Mergecount = Range("A4").MergeArea.Cells.Count

    End Function

    then in a cell
    = MergeCount(A5)

    "Kanaski79" wrote:

    > Don't know if you saw my other post, but it was about finding out how many
    > cells a merged cell group occupies. I need that number from the macro that
    > someone responded with to use that as the range for the lookup and max
    > functions. Do you think that would work?
    >
    > this was the macro they gave me.
    >
    > Sub test()
    > ActiveCell.Value = Format(Date, "dd-mmm-yyyy")
    > End Sub
    >
    > Thanks
    >
    > Kevin
    >
    > "Vacation's Over" wrote:
    >
    > > If you convert your macro to a function then a function can call another
    > > function.
    > >
    > > Although there are many exceptions: a macro does something and a function
    > > returns a value. So a function looking for information would be expected to
    > > call another function.
    > >
    > > "Kanaski79" wrote:
    > >
    > > > Can a Function call a macro? Say during a sort or lookup opperation you want
    > > > some special data that the macro returns?
    > > >
    > > > Kevin


  5. #5
    Kanaski79
    Guest

    RE: functions

    Ok this may sound like s stupid question. Where do you enter all this code?
    I do have some programming experience but I have never written anything for
    excell. Never needed to untill now. Small example would be greatly helpfull.

    Thanks again

    Kevin

    "Vacation's Over" wrote:

    > User defined functions:
    > Create your own function simply by using Function instead of Sub. Then set
    > your function = value you require
    >
    > Function MergeCount(Cellref as range) as Integer
    >
    > Mergecount = Range("A4").MergeArea.Cells.Count
    >
    > End Function
    >
    > then in a cell
    > = MergeCount(A5)
    >
    > "Kanaski79" wrote:
    >
    > > Don't know if you saw my other post, but it was about finding out how many
    > > cells a merged cell group occupies. I need that number from the macro that
    > > someone responded with to use that as the range for the lookup and max
    > > functions. Do you think that would work?
    > >
    > > this was the macro they gave me.
    > >
    > > Sub test()
    > > ActiveCell.Value = Format(Date, "dd-mmm-yyyy")
    > > End Sub
    > >
    > > Thanks
    > >
    > > Kevin
    > >
    > > "Vacation's Over" wrote:
    > >
    > > > If you convert your macro to a function then a function can call another
    > > > function.
    > > >
    > > > Although there are many exceptions: a macro does something and a function
    > > > returns a value. So a function looking for information would be expected to
    > > > call another function.
    > > >
    > > > "Kanaski79" wrote:
    > > >
    > > > > Can a Function call a macro? Say during a sort or lookup opperation you want
    > > > > some special data that the macro returns?
    > > > >
    > > > > Kevin


  6. #6
    Vacation's Over
    Guest

    RE: functions

    Yea, it's kind of weird. Ever since Excel 5.0 back in the early 90's VBA has
    been "easily" accessable from Excel. But, as you point out it is just a bit
    hidden.

    If you dare to see how deep the rabbit hole goes.....
    click on a cell then hold alt and hit F11

    You are now in the VBE - Visual Basic Editor and can see any code attached
    to your workbook

    And you should read a good book .....Google - j Walk (worked for me...)

    "Kanaski79" wrote:

    > Ok this may sound like s stupid question. Where do you enter all this code?
    > I do have some programming experience but I have never written anything for
    > excell. Never needed to untill now. Small example would be greatly helpfull.
    >
    > Thanks again
    >
    > Kevin
    >
    > "Vacation's Over" wrote:
    >
    > > User defined functions:
    > > Create your own function simply by using Function instead of Sub. Then set
    > > your function = value you require
    > >
    > > Function MergeCount(Cellref as range) as Integer
    > >
    > > Mergecount = Range("A4").MergeArea.Cells.Count
    > >
    > > End Function
    > >
    > > then in a cell
    > > = MergeCount(A5)
    > >
    > > "Kanaski79" wrote:
    > >
    > > > Don't know if you saw my other post, but it was about finding out how many
    > > > cells a merged cell group occupies. I need that number from the macro that
    > > > someone responded with to use that as the range for the lookup and max
    > > > functions. Do you think that would work?
    > > >
    > > > this was the macro they gave me.
    > > >
    > > > Sub test()
    > > > ActiveCell.Value = Format(Date, "dd-mmm-yyyy")
    > > > End Sub
    > > >
    > > > Thanks
    > > >
    > > > Kevin
    > > >
    > > > "Vacation's Over" wrote:
    > > >
    > > > > If you convert your macro to a function then a function can call another
    > > > > function.
    > > > >
    > > > > Although there are many exceptions: a macro does something and a function
    > > > > returns a value. So a function looking for information would be expected to
    > > > > call another function.
    > > > >
    > > > > "Kanaski79" wrote:
    > > > >
    > > > > > Can a Function call a macro? Say during a sort or lookup opperation you want
    > > > > > some special data that the macro returns?
    > > > > >
    > > > > > Kevin


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1