+ Reply to Thread
Results 1 to 6 of 6

Assign formula to a Sheet Cell through a VBA Form

  1. #1
    Registered User
    Join Date
    07-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    3

    Exclamation Assign formula to a Sheet Cell through a VBA Form

    Hello

    My Problem is:

    The Worksheet "Stock" is just for viewing data and no inputs are to be done.
    Structure of my excel file.
    Upon clicking Add Button, VBA Form opens up. This form adds the data to the next sequence sr. no. row.
    It also duplicates worksheet "Blankformat" and renames it to the Sr. No. generated by it in the previous step.
    So couple of worksheets names 1,2,3,4,5..... will be generated.

    I want to built-in the same VBA Form the ability to assign formula to the "Stock" cells and pull the data from Worksheets 1,2,3,4,5,...

    Example

    Cell(4,2), Cell(4,3), Cell(4,4), Cell(4,5) etc of WS("Stock") to be assigned formula =C2, =C3, as so on. of WS 1

    Appreciate help in this case.

    -Nimesh

    Help.xlsm
    Last edited by Cutter; 07-22-2012 at 11:15 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Assign formula to a Sheet Cell through a VBA Form

    Nimesh:

    you can use following format to assign formula:

    Please Login or Register  to view this content.
    Last edited by Cutter; 07-22-2012 at 11:15 AM. Reason: Added code tags
    Regards,
    Vandan

  3. #3
    Registered User
    Join Date
    07-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Assign formula to a Sheet Cell through a VBA Form

    Hello Vandan

    Thanks for the reply.

    I am aware of this function. But my problem is how should I define SheetName in this case as SheetName is generated by the sub function at the time of clicking the Add button.

    Looking forward to some solution.

    Thanks

  4. #4
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Assign formula to a Sheet Cell through a VBA Form

    Hi,

    Do you want a formula or values. You can tell the code to write values in each tab and then write them in the Summary sheet. or use WS as reference when using the formula R1C1 to populate the summary.

  5. #5
    Registered User
    Join Date
    07-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Assign formula to a Sheet Cell through a VBA Form

    Hi Fredlo

    I didn't understand what you mean....

    My problem is syntax to point SheetName (in my case - NewWS is the SheetName generated) which is String but it doesn't work when used in Cell(R,C).formula equation.

    Nimesh

  6. #6
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Assign formula to a Sheet Cell through a VBA Form

    Every time I need to use a R1C1 formula I record it using the macro recorder. You will get it in a blink of an eye.

    Then you change it to fit you needs and though it in the loop. I wish I could help more but I am a newbie too

+ Reply to Thread

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