Maranda022
Technical User
Hello,
Each year, companies input metric data into this workbook. I am developing a Macro that needs to update all tables and charts (stored in seperate worksheets) with new data. The attachment contains an example of how the is the source data is stored for each chart. Charts are stored in seperate individual worksheets.
Current Macro functionality searches for key word "Insert"on line 7 then adds a new column.
Need it to copy and paste C Values into new D column, then formulas need to be udpated so the row number is incremented by 1
Same needs to happen on line 18. i.e. search for "insert," but the new column has already been created, so the c values just need to be copied into column d and incremented by 1.
All source data is on separate worksheets i.e. company 1, company 2, etc… the data is stored the same way on each worksheet.
The number of companies and Tables will vary over time, so I will need to incorporate loops
Next Macro will need to update chart source data to include/display the data for the new year. Any help on this macro will be greatly appreciated as well!
Current Macro code (comments include code from recorded macro, that essentially does what I need to do, but the columns/ranges will vary):
Sub SearchAndInsertcolumn()
For i = 1 To Sheets.Count
If Worksheets(i).Name Like "Reg" & "*" Then
Worksheets(i).Activate
Dim SearchRange As Range
Dim FindWhat As Variant
Dim FoundCells As Range
Dim FoundCell As Range
Set SearchRange = Rows("7")
FindWhat = "Insert"
Set FoundCells = FindAll(SearchRange:=SearchRange, _
FindWhat:=FindWhat, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
MatchCase:=False)
If FoundCells Is Nothing Then
Debug.Print "Value Not Found"
Else
For Each FoundCell In FoundCells
Debug.Print "Value Found In Cell: " & FoundCell.Address(False, False)
FoundCell.EntireColumn.Insert
Debug.Print "Value Found In Cell after insert: " & FoundCell.Address(False, False)
'Range("D7
18").Select
' Selection.Copy
'Range("E7").Select
'ActiveSheet.Paste
'Range("E7").Select
'Application.CutCopyMode = False
'Range("E8").Select
'ActiveCell.FormulaR1C1 = "='ACN Metrics'!R[25]C25"
'Range("E9").Select
'ActiveCell.FormulaR1C1 = "='Cadence Metrics'!R[24]C25"
'Range("E10").Select
'ActiveCell.FormulaR1C1 = "='Cisco Metrics'!R[23]C25"
'Range("E11").Select
'ActiveCell.FormulaR1C1 = "='Deloitte Metrics'!R[22]C25"
'Range("E12").Select
'ActiveCell.FormulaR1C1 = "='HP Metrics'!R[21]C25"
'Range("E13").Select
'ActiveCell.FormulaR1C1 = "='Microsoft Metrics'!R[20]C25"
'Range("E15").Select
'ActiveCell.FormulaR1C1 = "='Nortel Metrics'!R[18]C25"
'Range("E16").Select
'ActiveCell.FormulaR1C1 = "='Novell Metrics'!R[17]C25"
'Range("E17").Select
'ActiveCell.FormulaR1C1 = "='Unisys Metrics'!R[16]C[21]"
'Range("E18").Select
'Columns("E:E").EntireColumn.AutoFit
Next FoundCell
End If
End If
Next
End Sub
Each year, companies input metric data into this workbook. I am developing a Macro that needs to update all tables and charts (stored in seperate worksheets) with new data. The attachment contains an example of how the is the source data is stored for each chart. Charts are stored in seperate individual worksheets.
Current Macro functionality searches for key word "Insert"on line 7 then adds a new column.
Need it to copy and paste C Values into new D column, then formulas need to be udpated so the row number is incremented by 1
Same needs to happen on line 18. i.e. search for "insert," but the new column has already been created, so the c values just need to be copied into column d and incremented by 1.
All source data is on separate worksheets i.e. company 1, company 2, etc… the data is stored the same way on each worksheet.
The number of companies and Tables will vary over time, so I will need to incorporate loops
Next Macro will need to update chart source data to include/display the data for the new year. Any help on this macro will be greatly appreciated as well!
Current Macro code (comments include code from recorded macro, that essentially does what I need to do, but the columns/ranges will vary):
Sub SearchAndInsertcolumn()
For i = 1 To Sheets.Count
If Worksheets(i).Name Like "Reg" & "*" Then
Worksheets(i).Activate
Dim SearchRange As Range
Dim FindWhat As Variant
Dim FoundCells As Range
Dim FoundCell As Range
Set SearchRange = Rows("7")
FindWhat = "Insert"
Set FoundCells = FindAll(SearchRange:=SearchRange, _
FindWhat:=FindWhat, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
MatchCase:=False)
If FoundCells Is Nothing Then
Debug.Print "Value Not Found"
Else
For Each FoundCell In FoundCells
Debug.Print "Value Found In Cell: " & FoundCell.Address(False, False)
FoundCell.EntireColumn.Insert
Debug.Print "Value Found In Cell after insert: " & FoundCell.Address(False, False)
'Range("D7
' Selection.Copy
'Range("E7").Select
'ActiveSheet.Paste
'Range("E7").Select
'Application.CutCopyMode = False
'Range("E8").Select
'ActiveCell.FormulaR1C1 = "='ACN Metrics'!R[25]C25"
'Range("E9").Select
'ActiveCell.FormulaR1C1 = "='Cadence Metrics'!R[24]C25"
'Range("E10").Select
'ActiveCell.FormulaR1C1 = "='Cisco Metrics'!R[23]C25"
'Range("E11").Select
'ActiveCell.FormulaR1C1 = "='Deloitte Metrics'!R[22]C25"
'Range("E12").Select
'ActiveCell.FormulaR1C1 = "='HP Metrics'!R[21]C25"
'Range("E13").Select
'ActiveCell.FormulaR1C1 = "='Microsoft Metrics'!R[20]C25"
'Range("E15").Select
'ActiveCell.FormulaR1C1 = "='Nortel Metrics'!R[18]C25"
'Range("E16").Select
'ActiveCell.FormulaR1C1 = "='Novell Metrics'!R[17]C25"
'Range("E17").Select
'ActiveCell.FormulaR1C1 = "='Unisys Metrics'!R[16]C[21]"
'Range("E18").Select
'Columns("E:E").EntireColumn.AutoFit
Next FoundCell
End If
End If
Next
End Sub