+ Reply to Thread
Results 1 to 7 of 7

A solution to make every cell in a range always have the same formula?

  1. #1
    Registered User
    Join Date
    06-19-2011
    Location
    blackpool, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    A solution to make every cell in a range always have the same formula?

    I 'm trying to make a workbook where for example, sheet2 column b from cell 2:300 will always have a formula in it, all with identical formula's

    What I want is lets say someone inserts a row into row 250, the cell wont just be pushed down so that the new cell is now blank, and that the 301 now has the formula in it when it was blank before.

    so lets say, the formula is '=2' , cells B2:B300 will always contain the formula, '=2' no matter if I delete or add cells, cells B2:B300 will never hold any other data besides '=2'

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: A solution to make every cell in a range always have the same formula?

    Hi,

    Place this in sheet2

    .
    Please Login or Register  to view this content.
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #3
    Registered User
    Join Date
    06-19-2011
    Location
    blackpool, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: A solution to make every cell in a range always have the same formula?

    Quote Originally Posted by realniceguy5000 View Post
    Hi,

    Place this in sheet2

    .
    Please Login or Register  to view this content.
    This looks good, however, what if I want to do the formula so that it ='Sheet1' + whatever row I'm currently using in on sheet 2 to reference sheet 1

    so in row7 ='sheet1'!B7
    row8 ='sheet1'B8

    and so on and so forth, however, I can it done hard coded as with the programming code given, all I need now is the answer to get it to change in each row

  4. #4
    Registered User
    Join Date
    06-19-2011
    Location
    blackpool, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: A solution to make every cell in a range always have the same formula?

    I think I can work it out myself, however I'm having problems including ' into a string?


    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim I As Integer

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    For I = 7 To 500
    Range("C" & I).Formula = "='Sheet1'!C" + I

    Next I
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    End Sub
    Last edited by Djarn; 07-01-2011 at 12:42 PM.

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: A solution to make every cell in a range always have the same formula?

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  6. #6
    Registered User
    Join Date
    06-19-2011
    Location
    blackpool, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: A solution to make every cell in a range always have the same formula?

    I hope the correction is better

  7. #7
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: A solution to make every cell in a range always have the same formula?

    maybe without loop ?
    Please Login or Register  to view this content.
    Best Regards
    MaczaQ

+ 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