Closed Thread
Results 1 to 2 of 2

Error message: Run-Time error '1004 '; application-defined or object-defined error

  1. #1
    Registered User
    Join Date
    10-22-2015
    Location
    oldham
    MS-Off Ver
    2013
    Posts
    3

    Error message: Run-Time error '1004 '; application-defined or object-defined error

    Hi

    I am fairly new to function/vba and I have tried to create a pin gernerator using the following function
    Public Function RandomizeF(Num1 As Integer)

    Dim Rand As String
    Application.Volatile
    getLen = Num1
    Do
    j = j + 1
    Randomize
    Rand = Rand & Chr(Int((85) * Rnd + 38))
    Loop Until j = getLen
    RandomizeF = Rand
    End Function

    and then calling it through

    Private Sub CommandButton1_Click()
    Dim myvalue As Integer, myvalue2 As Integer, i As Integer

    myvalue = InputBox("enter number between 5 and 10")
    myvalue2 = InputBox("enter number of pins required")
    For i = 1 To myvalue2
    Cells(i, 1).Value = RandomizeF(myvalue)
    Next i

    End Sub
    When asking for large numbers of pins (i have been testing with 100 but will require more) it sometimes works but other times throws the error shown it the title. When opening the debug the line Cells(i, 1).Value = RandomizeF(myvalue) is shown as the error

    Any ideas as what is causing this and how to correct it.

    Many thanks

    Dave

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Error message: Run-Time error '1004 '; application-defined or object-defined error

    Hi, Dave,

    Forum issues might have made it impossible to check but this is a duplictae thread to http://www.excelforum.com/excel-prog...ned-error.html.

    Anyhow you should wrap your procedures in Code-Tags as required by Forum Rule #3.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 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
  2. excel macro run time error '1004'- Application defined or object defined error
    By kmadan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 09:51 AM
  3. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  4. [SOLVED] Run time error 1004 Application-Defined or Object-Defined Error - Placing data into next e
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-27-2014, 12:57 PM
  5. [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
  6. [SOLVED] run-time error '1004' application-defined or object-defined error - Excel 2007
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2012, 02:46 AM
  7. Macro - Run-time Error '1004': Application defined or object defined error
    By robby10 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2010, 07:55 AM

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