Link values between 2 cells, same row different columns

kromer12

New Member
Joined
Jun 25, 2015
Messages
5
Hello All,

I have a sheet that has a list of sheet names that "live" updates, when a new sheet is added or a sheet is moved in the workbook the list updates accordingly to keep the order the sheets are in. However, the column next to that list of names allows the user to place an "x" in cell to exclude that row from being calculated into an average at the top. When the list of sheet names updates and sheet "6-5-15" moves down one row the "x" that was placed in the column next to it needs to move with it so that row is still excluded from the averages.

Below is an example of the list of sheet names and the "x" column and the current code I am attempting to use.

When sheet "6-27-15" is created it is added to row 13 automatically using an array formula, but the x needs to move from row 13 to row 14 to align with sheet name "6-26-15"

BFGUV
12Exclude(x)(Sheet Names)BoxesOld (x)Old List
13x6-27-15100x6-26-15
146-26-151206-25-15
156-25-1590

<tbody>
</tbody>


Code:
    Dim m_lngNSheets As Long

    Private Sub Workbook_Open()    m_lngNSheets = ThisWorkbook.Sheets.Count
    
    Worksheets("Main").Range("B13:B600").Copy
    Worksheets("Main").Range("U13").PasteSpecial Paste:=xlPasteValues
    Worksheets("Main").Range("F13:F600").Copy
    Worksheets("Main").Range("V13").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    ActiveSheet.Range("A1").Select


End Sub


Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Dim main As Worksheet, i As Integer, urow As String, uday As String
    
    If ThisWorkbook.Sheets.Count > m_lngNSheets Then
        MsgBox "New Sheet Copied or Added " & Sh.Name
    End If
    m_lngNSheets = ThisWorkbook.Sheets.Count
    
    Set main = Sheets("Main")
    i = 13
    Do Until main.Cells(i, 6).Value = ""
        uday = main.Cells(i, 22).Value
        If main.Cells(i, 6).Value = uday Then
        Else
            urow = Application.WorksheetFunction.Match(uday, Range("F1:F600"), 0)
            main.Cells(urow, 2).Value = main.Cells(i, 21).Value
        End If
        i = i + 1
    Loop
     
    End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Problem solved! Instead of allowing a user to manually copy/move tabs I added a macro to create the new tab and move the "x"s in column b to match.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top