+ Reply to Thread
Results 1 to 10 of 10

Getting error Sub of Function not defined

  1. #1
    Forum Contributor
    Join Date
    01-06-2019
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    209

    Getting error Sub of Function not defined

    Please Login or Register  to view this content.
    It has only done it after I wanted to do the if part, as I want to do an if .Shapes("MonOn").Visible = msoCTrue do that function , if .Shapes("TuesOn").Visible = msoCTrue then do slightly different function looking at a different range of cells.

    Thank you for your help in advance

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Getting error Sub of Function not defined

    Hello
    Not clear. Can you upload sample of your workbook with your desired output?
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Contributor
    Join Date
    01-06-2019
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    209

    Re: Getting error Sub of Function not defined

    Ok think of it "MonOn " "TuesOn" are shapes that are used for Tabs so there is a "MonOff" "TuesOFF"

    As MonOn is Visible then from sheet 3 where for example you have all the numbers of the lottery 1 - 45 from that selection (Sheet3 B5:I10 with blanks) you want to select 6 numbers randomly without duplicates in the same row in sheet 1 C5:H23
    But if Tues on is Visible then the ranges for the data and the destination change and is randomly 7 numbers not 6.

    Hope this helps if not I will try and upload my excel file . That is if my keyboard hasn't stopped working

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Getting error Sub of Function not defined

    Where does this come from ?
    Please Login or Register  to view this content.
    And if you want your range to come from Sheet3 you shoul do like this.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Contributor
    Join Date
    01-06-2019
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    209

    Re: Getting error Sub of Function not defined

    The Set Cell = RdmCell(Rng) is to randomly select cells from rng(B5:I10)

    changing to .range did not make any difference to the error

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Getting error Sub of Function not defined

    Please Login or Register  to view this content.
    I don't know where you got that but when I run your code it's that line that's going into the error that you discribe.

  7. #7
    Forum Contributor
    Join Date
    01-06-2019
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    209
    Quote Originally Posted by bakerman2 View Post
    Please Login or Register  to view this content.
    I don't know where you got that but when I run your code it's that line that's going into the error that you discribe.
    Twinnyfo from here wrote the original code and it did work in my other excel file.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Getting error Sub of Function not defined

    Can you post an example file with all your code so we can test.

    As I thought, RmdCell is a seperate UDF.
    For future helpers.
    Please Login or Register  to view this content.
    PS
    Works fine for me like this.
    Please Login or Register  to view this content.
    Last edited by bakerman2; 01-19-2019 at 06:59 AM. Reason: Added UDF RmdCell

  9. #9
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,409

    Re: Getting error Sub of Function not defined

    Perhab
    Please Login or Register  to view this content.
    Last edited by daboho; 01-19-2019 at 09:07 AM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

  10. #10
    Forum Contributor
    Join Date
    01-06-2019
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    209

    Re: Getting error Sub of Function not defined

    I forgot to add this code, sorry my mind was somewhere else. But it is solved now

    Function RdmCell(rng As Range) As Range
    Set RdmCell = rng.Cells(Int(Rnd * rng.Cells.Count) + 1)
    End Function

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  5. [SOLVED] Run Time 1004 - App Defined or Object defined error with String defined path structure
    By sarails in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2012, 09:38 PM
  6. Application Defined or Object Defined Error, Command Button and Vlookup Function
    By stevedomer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2011, 11:20 PM
  7. [SOLVED] Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 PM

Tags for this Thread

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