I have several sheets in a workbook where if there are multiples of a number in a list I need to move an adjacent column over 1. This adjacent column is being used in a formula in the sheet. I want the formula to reference the value in its new position.
This is the table before the code
This is the ideal result where all the ones and fives had their numbers moved over 1 column but the formula still references the cell.
I've written:
For i = 1 To WS_Count sheet_name = ActiveWorkbook.Worksheets(i).Name row_count = Worksheets(sheet_name).Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row For x = 11 To row_count cell = ActiveWorkbook.Worksheets(sheet_name).Cells(x, 1) If cell = "" Then GoTo NextIteration If ActiveWorkbook.Worksheets(sheet_name).Cells(x - 1, 1) = ActiveWorkbook.Worksheets(sheet_name).Cells(x, 1) Or ActiveWorkbook.Worksheets(sheet_name).Cells(x + 1, 1) = ActiveWorkbook.Worksheets(sheet_name).Cells(x, 1) Then ActiveWorkbook.Worksheets(sheet_name).Cells(x, 5) = ActiveWorkbook.Worksheets(sheet_name).Cells(x, 4) ActiveWorkbook.Worksheets(sheet_name).Cells(x, 4).ClearContents End If NextIteration: Next x Next i The cut is not working properly over the multiple sheets. It doesn't properly move to the new sheet.
Is there a way to move a cell's value and the reference to the cell from the formula over multiple sheets?


Range.Cut