+ Reply to Thread
Results 1 to 8 of 8

Adjust formula to allow for changing sheet reference.

Hybrid View

  1. #1
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Post Re: Adjust formula to allow for changing sheet reference.

    Hi JB,

    Yes I was thinking about a macro, but would some type of loop work replacing each sheet reference with the next variable starting from 1?

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Post Re: Adjust formula to allow for changing sheet reference.

    Hi again JB,

    So far I have come up with this, but it change the '1' to '2' throughout the range B1:H1. What am I missing to make it loop through all the numbers up to 7. I am just testing a small scale right now so therefore up to only 7.

    Sub FixFormula()
    Application.DisplayAlerts = False
    Dim y As Integer
        For y = 2 To 7
            With Sheets(CStr("Sheet1")).Range("B1:H1")
                .Cells.Replace What:="'1'", _
                Replacement:="'" & y & "'", _
                LookAt:=xlPart, _
                SearchOrder:=xlByRows, _
                MatchCase:=False, _
                SearchFormat:=False, _
                ReplaceFormat:=False
            End With
        Next y
    Application.DisplayAlerts = True
    End Sub

+ 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