+ Reply to Thread
Results 1 to 3 of 3

Copying a Formula but using current row details

  1. #1
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    464

    Copying a Formula but using current row details

    Hello,

    I was hoping someone could help with this problem please?

    I have a formula in cell A1 (=B1+C1)

    I would like my VB loop to run through cells A1:A50 and if the cell is empty then insert that formula but using the details for that row.

    So if the loop gets to cell A15 and finds that it is empty, it will populate it with the formula =B15+C15.

    Note: Because of restrictions in my code I cannot simply ask VB to copy cell A1 and paste into cell A15.

    The restriction is that after every change in the worksheet, it automaticallys protects it again so you cannot paste because the copy has been cancelled.

    I would really appreciate any help on this.

    Thanks a lot

    John

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by johncassell
    Hello,

    I was hoping someone could help with this problem please?

    I have a formula in cell A1 (=B1+C1)

    I would like my VB loop to run through cells A1:A50 and if the cell is empty then insert that formula but using the details for that row.

    So if the loop gets to cell A15 and finds that it is empty, it will populate it with the formula =B15+C15.

    Note: Because of restrictions in my code I cannot simply ask VB to copy cell A1 and paste into cell A15.

    The restriction is that after every change in the worksheet, it automaticallys protects it again so you cannot paste because the copy has been cancelled.

    I would really appreciate any help on this.

    Thanks a lot

    John
    Assuming something like iRow as your row counter, then

    Range("A" & iRow).Formula = "=B" & iRow & "+C" & iRow

    should go close.

    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    464
    Cheers Bryan,

    Wasn't exactly what I was looking for but it has given my brain a push in the right direction and now think ive sorted it.

    Thanks for replying, much appreciated.

    John

+ 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.6.0 RC 1