Hi- I am new-ish to VBA and first code using the scripting dictionary which I am still trying to understand.
I am trying to write a code that will copy, search/match and then paste specific cells from one workbook to another workbook. The code below is mostly doing the job.
The only issue that I am having is keeping the formatting. For example, if a cell is bolded in the workbook that I am copying from, it is not bolded when it has been pasted into the other workbook.
Any help is appreciated. Thank you for taking the time!
I am trying to write a code that will copy, search/match and then paste specific cells from one workbook to another workbook. The code below is mostly doing the job.
The only issue that I am having is keeping the formatting. For example, if a cell is bolded in the workbook that I am copying from, it is not bolded when it has been pasted into the other workbook.
Any help is appreciated. Thank you for taking the time!
VBA Code:
Sub IS_to_RT()
Dim Cl As Range
Dim Dic As Object
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Do you have the RT spreadsheet open and named:" & Chr(13) & Chr(10) & "2022 RT Report", vbYesNo + vbQuestion, "Ready to update the RT Report?")
If Answer = vbYes Then
' Fill in column Manager
Set Dic = CreateObject("scripting.dictionary")
With Workbooks("IT Workplan.xlsm").Sheets("2022")
For Each Cl In .Range("C3", .Range("C" & Rows.Count).End(xlUp))
Dic(Cl.Value) = Cl.Offset(, -1).Value
Next Cl
End With
With Workbooks("2022 RT Report.xlsx").Sheets("RT Report")
For Each Cl In .Range("M4", .Range("M" & Rows.Count).End(xlUp))
If Dic.exists(Cl.Value) Then Cl.Offset(, -9).Value = Dic(Cl.Value)
Next Cl
End With
' Fill in column Current Status
Set Dic = CreateObject("scripting.dictionary")
With Workbooks("IT Workplan.xlsm").Sheets("2022")
For Each Cl In .Range("C3", .Range("C" & Rows.Count).End(xlUp))
Dic(Cl.Value) = Cl.Offset(, 4).Value
Next Cl
End With
With Workbooks("2022 RT Report.xlsx").Sheets("RT Report")
For Each Cl In .Range("M4", .Range("M" & Rows.Count).End(xlUp))
If Dic.exists(Cl.Value) Then Cl.Offset(, 1).Value = Dic(Cl.Value)
Next Cl
End With
MsgBox "RT Report has been updated", vbOKOnly, "Finished"
Else
MsgBox "No changes made." & Chr(13) & Chr(10) & "If you wish to update the RT Report spreadsheet, please ensure it is open and named:" & Chr(13) & Chr(10) & "2022 RT Report", vbOKOnly + vbInformation, "Attention"
Exit Sub
End If
End Sub