+ Reply to Thread
Results 1 to 4 of 4

vba #REF! error

  1. #1
    Registered User
    Join Date
    12-14-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    41

    vba #REF! error

    Hi guys,


    I have got the following problem. I have a sheet "calculations" that uses references from another sheet "calendar". In the calculations sheet I have got formulas - =COUNTIF(Calendar!$B4:$AF4,"P"), =COUNTIF(Calendar!$B5:$AF5,"U") and so on. In other words, I use some references from the calendar sheet. I have got a userform with delete button which deletes the entire row in the calendar sheet and also the same row in the calculations sheet. However, the row above the deleted one in the calculations sheet gets distorted with #REF! error. The references are lost for some reason. This all is done automatically by a macro. I have read some articles about the indirect function that may help. However, I am not quite sure how to use it.

    Any ideas?

    Thanks

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

    Re: vba #REF! error

    Hi, dulitul,

    too little input from your side for me to be of any help as you do not indicate how the formulas look like which loose their references. IŽd expected this question to be a Forumla/Function one opposite to this being asked in VBA/Macros.

    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

  3. #3
    Registered User
    Join Date
    12-14-2012
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: vba #REF! error

    Hi,

    Sorry about the confusion. I think I found the right answer and it is to use the indirect function like this- =COUNTIF(INDIRECT("Calendar!$B4:$AF4"),"P"). However,
    now I have encountered another problem with autofilling the cells. When I paste the formula and try to autofill the references do not increment automatically. In other words =COUNTIF(INDIRECT("Calendar!$B4:$AF4"),"P") does not become =COUNTIF(INDIRECT("Calendar!$B5:$AF5"),"P") and so on. Any ideas how to solve it? The option calcuate automatically is on.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: vba #REF! error

    I'm afraid your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    HTH
    Regards, Jeff

+ 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