Hi,
I am currently using the following code obtained from here to copy a target row from one workbook to another. The sheet I am copying from has coloured cells, conditional formatting and 2 objects (buttons) on each row. The code works just fine, but I would like to know if it would be possible to modify it so that it only copies specific cells on the row instead of the whole row and removes the formatting so that all it copies across are the cell values.
The code I am currently using is as follows.
Sub CopyDeliveryData(Target As Range)
Dim DstPath As String
Dim DstWkb As Workbook
Dim DstWks As Worksheet
Dim DataRng As Range
Dim R As Long
Dim SrcWks As Worksheet
Set SrcWks = ThisWorkbook.ActiveSheet
Set DataRng = SrcWks.Range("A6:Q255")
DstPath = ThisWorkbook.Path & "\PPM DATABASE SHEETS\"
Application.ScreenUpdating = False
'Make sure the folder path ends with a backslash
DstPath = IIf(Right(DstPath, 1) <> "\", DstPath & "\", DstPath)
On Error Resume Next
'ignore potential error and resume execution on the next line of code
Set DstWkb = Workbooks("STAFF PPM LOGS.xls")
'this makes sure that if the workbook, worksheet does not exist, error 9 -Subscript Out of Range, it will creat it
'the code below will creat the workbook if does not exist
If Err = 9 Then
Set DstWkb = Workbooks.Open(DstPath & "STAFF PPM LOGS.xls")
Err.Clear
End If
On Error GoTo 0
R = Target.Row - DataRng.Row + 1
Set DstWks = DstWkb.Worksheets(Target.Value)
DataRng.Cells(R, 1).Resize(1, 15).Copy DstWks.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
ActiveWindow.Close savechanges:=True
Application.ScreenUpdating = True
Thanks in advance
Bookmarks