Notifications
Clear all
VBA & Macros
2
Posts
2
Users
0
Reactions
25
Views
Topic starter
I have a file that I want to import the data that have been coloured using Conditional formatting
I have code to open a file, but need this amended to only copy the data that has been coloured containing conditional formatting
Your assistance in resolving this is most appreciated
Sub Open_and_CopyFile() ' Application.ScreenUpdating = False Application.EnableEvents = False Application.Calculation = xlCalculationManual Application.DisplayAlerts = False Dim nb As Workbook, ts As Worksheet, A As Variant Dim rngDestination As Range Sheets(1).Select Set ts = ActiveSheet On Error Resume Next Set rngDestination = ts.[A1] On Error GoTo 0 If rngDestination Is Nothing Then Exit Sub ChDir ("C:my Documents") With Application.FileDialog(msoFileDialogFilePicker) .InitialFileName = "*Conditional*.xls*" If .Show = 0 Then Exit Sub A = .SelectedItems(1) End With ' A = Application.GetOpenFilename ' If A = False Or IsEmpty(A) Then Exit Sub Application.ScreenUpdating = False Set nb = Workbooks.Open(A) ThisWorkbook.Activate nb.Sheets(1).Range("A3:D50").Copy rngDestination.PasteSpecial Paste:=xlPasteValues rngDestination.PasteSpecial Paste:=xlPasteFormats Application.CutCopyMode = False nb.Close savechanges:=False Application.ScreenUpdating = True Application.EnableEvents = True Application.Calculation = xlCalculationAutomatic Application.DisplayAlerts = False End SubI have also posted on Macro to import data containing Conditional formatting (excelforum.com)
Posted : 14/07/2021 1:11 pm
Answered on Excel Forum
Posted : 18/07/2021 8:08 pm