wklej specjalne wartości w vba
Pracuję nad małym projektem, który wymaga od mnie skopiowania i wklejenia niektórych kolumn, jeśli wykryję „true” w wierszu. Próbuję wkleić wybrane kolumny do innego arkusza i chcę wkleić tylko ich wartości, a nie formuły.
To jest to, co mam do tej pory i pojawia się błąd z funkcją specjalną wklejania. Proszę pomóż.
' CopyIfTrue()
Dim Col As Range, Cell As Excel.Range, RowCount As Integer
Dim nysheet As Worksheet
Set nysheet = Sheets.Add()
nysheet.Name = "T1"
Sheets("FemImplant").Select
RowCount = ActiveSheet.UsedRange.Rows.Count
Set Col = Range("I2:I" & RowCount) 'Substitute with the range which includes your True/False values
Dim i As Integer
i = 1
For Each Cell In Col
If Cell.Value = "True" Then
Cell.Copy
Sheets("T1").Select 'Substitute with your sheet
Range("b" & i).Select
ActiveSheet.Paste
'Get sibling cell
Sheets("FemImplant").Select
Dim thisRow As Integer
thisRow = Cell.Row
Dim siblingCell As Range
Set siblingCell = Cells(thisRow, 2)
siblingCell.Copy
Sheets("T1").Select 'Substitute with your sheet
Range("a" & i).Select
ActiveSheet.PasteSpecial Paste:=xlPasteValues
Sheets("FemImplant").Select
i = i + 1
End If
Next