Results 1 to 4 of 4

Thread: [RESOLVED] vba FormulaR1C1

  1. #1

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Resolved [RESOLVED] vba FormulaR1C1

    how can i write a FormulaR1C1 in vba?
    i want to set the formula in cell V2 to "=IF(SUM(B2:U2)>0,SUM(B2:U2),"")"

    how can i do that in my macro?

    question2: how do i filldown column V?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: vba FormulaR1C1

    =IF(SUM(RC[-20]:RC[-1])>0,SUM(RC[-20]:RC[-1]),"")
    to convert, put your formula in v2, then
    debug.print range("v2").FormulaR1C1
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: vba FormulaR1C1

    thanks. i worked it out by recording a macro.

    how about question 2?

    i need to filldown. i've got the column number + the last row used number, but i'm not sure of the syntax for filldown

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: vba FormulaR1C1

    The quickest way to fill down:
    Code:
    Sheet1.Range("V2:V300").FormulaR1C1 = "=IF(SUM(RC[-20]:RC[-1])>0,SUM(RC[-20]:RC[-1]),"""")"
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Posting Permissions

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



Click Here to Expand Forum to Full Width