Consulting

Results 1 to 5 of 5

Thread: Write formula in VBA-'Error 13'

  1. #1

    Write formula in VBA-'Error 13'

    I am trying to make a long code. My everything works smooth except i got stuck on this part of code.


    Sheets("SCB_Rejection_Working").Select
        Range("A5").Formula = "=IF(ROW($A1:A1)>COUNTIF(SCB_Rejection!A:A," * ")-1,"",SCB_Rejection!M2)"
    Your help is highly appreciable.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings wouldbeca,

    There is no reason to select the sheet first, but disregarding that for the moment, you need to 'double-up' the quote marks within the string, to have it write the formula to the sheet correctly.

      Sheets("SCB_Rejection_Working").Select
      Range("A5").Formula = "=IF(ROW($A1:A1)>COUNTIF(SCB_Rejection!A:A,""*"")-1,"""",SCB_Rejection!M2)"
    I hope that helps,

    Mark

  3. #3
    what is it supposed to do?
    row($a1:a1) will always have to return 1

  4. #4
    Actually, This formula I am going to auto fill o cells below in next step which I had not mentioned here.


    Quote Originally Posted by westconn1 View Post
    what is it supposed to do?
    row($a1:a1) will always have to return 1

  5. #5
    Thanks mate.. Cheers!!!

    Quote Originally Posted by GTO View Post
    Greetings wouldbeca,

    There is no reason to select the sheet first, but disregarding that for the moment, you need to 'double-up' the quote marks within the string, to have it write the formula to the sheet correctly.

      Sheets("SCB_Rejection_Working").Select
      Range("A5").Formula = "=IF(ROW($A1:A1)>COUNTIF(SCB_Rejection!A:A,""*"")-1,"""",SCB_Rejection!M2)"
    I hope that helps,

    Mark

Posting Permissions

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