Hi All,
I have 15 tabs in a workbook, the last columns in each of the tab have a formula for a specific year. I was wondering if there is a vba code that would indentify the formula in the specific columm, highlight this and copy it in the previous column. i tried recording this action but it specifies the column to highlight which wouldnt work going forward:
EDIT:
Maybe thinking about it, if the code searches "=Year", offset code to insert a column before it, then paste special values and do this for each of the tabs?
I have 15 tabs in a workbook, the last columns in each of the tab have a formula for a specific year. I was wondering if there is a vba code that would indentify the formula in the specific columm, highlight this and copy it in the previous column. i tried recording this action but it specifies the column to highlight which wouldnt work going forward:
VBA Code:
heets("Table 1").Select
Cells.Find(What:="=Year", After:=ActiveCell, LookIn:=xlFormulas2, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Columns("AI:AI").Select
Selection.Copy
Columns("AI:AI").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 2").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AI:AI").Select
Application.CutCopyMode = False
Selection.Copy
Columns("AI:AI").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 3").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AI:AI").Select
Application.CutCopyMode = False
Selection.Copy
Columns("AI:AI").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 4").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AI:AI").Select
Application.CutCopyMode = False
Selection.Copy
Columns("AI:AI").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 5").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AI:AI").Select
Application.CutCopyMode = False
Selection.Copy
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 6").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AI:AI").Select
Application.CutCopyMode = False
Selection.Copy
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=-10
Sheets("Table 7_SIC07").Select
Selection.FindNext(After:=ActiveCell).Activate
Selection.FindNext(After:=ActiveCell).Activate
Sheets("Table 9").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AI:AI").Select
Application.CutCopyMode = False
Selection.Copy
Columns("AI:AI").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 10_SOC20").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("D:D").Select
Application.CutCopyMode = False
Selection.Copy
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 12").Select
Selection.FindNext(After:=ActiveCell).Activate
Range("A1").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AI:AI").Select
Application.CutCopyMode = False
Selection.Copy
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 15").Select
Range("B1").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("AA:AA").Select
Application.CutCopyMode = False
Selection.Copy
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Table 7_SIC07").Select
Range("A1").Select
Cells.FindNext(After:=ActiveCell).Activate
Columns("T:T").Select
Application.CutCopyMode = False
Selection.Copy
Columns("T:T").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
EDIT:
Maybe thinking about it, if the code searches "=Year", offset code to insert a column before it, then paste special values and do this for each of the tabs?
Last edited by a moderator: