Results 1 to 2 of 2

Thread: Input Box for an excel macro?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    1

    Input Box for an excel macro?

    Alright, I have an extra credit project due at 2:30pm, and I am stuck on it.

    www.cse.psu.edu/~hansford/extraCreditProject.htm

    I have this code so far, i just can't finish it
    Sub InvestmentCalc()
    '
    ' InvestmentCalc Macro
    ' Macro recorded 4/13/2005 by jdh336
    '
    '
    Dim rng
    strRng = InputBox("Enter Last Cell To Be Filled")
    Range("G3:G10").Select
    ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
    Range("G3:g10").Select
    Selection.AutoFill Destination:=Range("G3:G6"), Type:=xlFillDefault
    Range("G3:strRng").Select
    End Sub

    I am getting a 1004 error telling me that "autofill method of range class failed"

    Can anyone help me?

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Input Box for an excel macro?

    not sure if you still need this..

    VB Code:
    1. Sub InvestmentCalc()
    2.  
    3. ' InvestmentCalc Macro
    4. ' Macro recorded 4/13/2005 by jdh336
    5.  
    6. Dim rng
    7.  
    8. strRng = InputBox("Enter Last Cell To Be Filled")
    9. Range("G3:G10").Select
    10. ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
    11. Range("G3:g10").Select
    12. Selection.AutoFill Destination:=Range("G3:G6"), Type:=xlFillDefault
    13. 'you were placing the variable within string quotation marks.
    14. Range("G3:" & strRng).Select
    15. End Sub
    if you fail to plan, you plan to fail

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