+ Reply to Thread
Results 1 to 5 of 5

VBA Formula showing error

  1. #1
    Registered User
    Join Date
    01-31-2018
    Location
    New Jersey
    MS-Off Ver
    2016
    Posts
    17

    VBA Formula showing error

    When I run this

    Sub lin()
    Dim i As Integer
    Dim j As Integer
    Dim c As Integer
    Dim d As String
    j = 138
    c = 1
    For i = 129 To Sheets.Count


    Worksheets("MML").Range("EH").Offset(0, c).Formula = "=" & Worksheets(CStr(Sheets(i).Name)).Range("E4").Address(External:=True)
    'i = i + 1
    j = j + 1
    c = c + 1
    Next i
    End Sub

    It shows objected-defined error at Bold line

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA Formula showing error

    Range("EH") is the problem I'm guessing.

    Do you have a named range called EH?
    Or should the H be a row number and this is a typo?

    BSB

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,373

    Re: VBA Formula showing error

    This is not valid: Range("EH")
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    01-31-2018
    Location
    New Jersey
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA Formula showing error

    It was my typo I figure it out.

    Thanks all

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,373

    Re: VBA Formula showing error

    You're welcome.



    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. Replies: 8
    Last Post: 06-27-2017, 10:36 AM
  2. Cell with Formula Not Showing Date - Only Showing Serial Number
    By jbb89777 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-07-2016, 04:33 AM
  3. IF(if error) showing #n/a
    By HPIMICHAEL02 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-14-2013, 11:19 AM
  4. Macro error, Formula cell showing a green triangle in top cell
    By sherry_1991 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2013, 02:09 PM
  5. Rank formula showing #VALUE! error
    By stats09 in forum Excel General
    Replies: 2
    Last Post: 12-06-2009, 08:53 PM
  6. Countif showing #value error
    By dodger999 in forum Excel General
    Replies: 3
    Last Post: 09-25-2009, 05:17 PM
  7. Vlookup Formula is showing error
    By kh0515 in forum Excel General
    Replies: 11
    Last Post: 01-12-2009, 05:37 PM

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