Sub CopyField()
Application.ScreenUpdating = False
Set sourceSheet = Sheets("Field Template")
Set targetSheet = Sheets("Field")
templateNumber = targetSheet.Range("h3")
templateName = sourceSheet.Range("M3").Offset(templateNumber, 0)
'find selected template
Set baseCell = sourceSheet.Range("A:A").Find(templateName, LookIn:=xlValues)
baseRow = baseCell.Row
'this version succesfully pastes just the unprotected cells and doesn't created errorneus results posting blank cells - BUT the formulas paste vs. just values
'Application.CutCopyMode = False
'sourceSheet.Range(sourceSheet.Cells(baseRow, 3), sourceSheet.Cells(baseRow + 10, 10)).Select
'Copy targetSheet.Range("C6")
'sourceSheet.Select
'this version successfully does a copy and past special but errorneous results pccur when the blank cells are posted
'Range(sourceSheet.Cells(baseRow, 3), sourceSheet.Cells(baseRow + 10, 10)).Select
'Selection.Copy
'Sheets("Field").Select
'Range("C6").Select
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
targetSheet.Range("D6").Value = sourceSheet.Range(sourceSheet.Cells(baseRow, 4), sourceSheet.Cells(baseRow + 10, 10)).Value
' this version succesfully pastes just the unprotected cells and doesn't created errorneus results posting blank cells - BUT the formulas paste vs. just values
For r = 0 To 10
For c = 4 To 10
With sourceSheet.Cells(baseRow + r, c)
If .Locked = False Then 'only copy unlocked cells
targetSheet.Cells(r + 6, c).Value = sourceSheet.Cells(baseRow + r, c).Value
End If
End With
Next c
Next r
Application.ScreenUpdating = True
End Sub
|