Results 1 to 12 of 12

Using Excel VBA to create formulas in cells dependant on user input

Threaded View

  1. #1
    Registered User
    Join Date
    04-19-2011
    Location
    Denmark
    MS-Off Ver
    Microsoft 365
    Posts
    15

    Using Excel VBA to create formulas in cells dependant on user input

    Dear Excel Users

    I am trying to write a VBA macro, which can create a worksheet with content. When this macro has been executed one time it won't be used anymore. The resulting worksheet should work on its own.

    I am unsure how to create formulas in the worksheet. Let's assume I wanted to place the formula "sum(A1:A5) in cell B4. Then I would just write the following in a code line:

    Cells(4,2) = "=sum(A1:A5)"

    The formulas are however not fixed as in the above example, but depends on user input. Suppose the user has delivered information about what cells to sum and what place to put that formula. Let's say I have defined two variables FR and FC containing the row and the column of the cell to place the formula, and suppose I have defined variables FromR, FromC, ToR and ToC specifying the range to sum. How do I write a code line to place the userspecified formula in the userspecified cell? I mean I can't just replace A1 and A5 with the userspecified range ...

    I hope someone can help solving this problem. I have considered the possibility of using names for ranges.

    Regards,

    Erik
    Last edited by erik11; 04-24-2011 at 06:57 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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