+ Reply to Thread
Results 1 to 2 of 2

Thread: VBA Code to enter formula in CELL

  1. #1
    Forum Contributor
    Join Date
    06-28-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    102

    VBA Code to enter formula in CELL

    Hello
    I wanna be able to click the button and the following code will be entered into cell B1

    currently I am using this code,
    for this code it is ActiveCell only if I am clicked on E29 it will write the formula in E29 but I want it like if I click the button or run Macro it will put the formula in B1

    Sub B1Macro()
    ActiveCell.Formula = "=PISampDat(COUNTER!$C$3,COUNTER!$A$7,COUNTER!$A$9,COUNTER!$A$11,0,""dmspi2p"")"
    End Sub

    ty

  2. #2
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: VBA Code to enter formula in CELL

    zit1343,

    Change ActiveCell to [B1]
    Sub B1Macro()
        [B1].Formula = "=PISampDat(COUNTER!$C$3,COUNTER!$A$7,COUNTER!$A$9,COUNTER!$A$11,0,""dmspi2p"")"
    End Sub


    Hope that helps,
    ~tigeravatar

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0