(Solved) – How do I copy values (and not the formatting) within a With..End With block?


I have tried incoperating .PasteSpecial xlPasteValues and .value in to the code. But can’t seem to get it right.

Private Sub CommandButton1_Click()

Dim wsSource, wsTarget As Worksheet
Dim i, iLastSource, iRowTarget, count As Long
Dim cell As Range

Set wsSource = Worksheets("Stig Jan")
iLastSource = wsSource.Cells(Rows.count, 1).End(xlUp).Row

Set wsTarget = Worksheets("Laura Jan")
count = 0
With wsSource
iRowTarget = wsTarget.Cells(Rows.count, 1).End(xlUp).Row   1
For i = 36 To iLastSource
  Set cell = .Cells(i, 4)
  If cell.Font.Bold = False Then
    If cell.Value = "Fælles" Or cell.Value = "Lagt Ud" Then
      .Rows(i).Columns("A:H").Copy.wsTarget.Range ("A" & iRowTarget)
      wsTarget.Range("D" & iRowTarget).ClearContents
      iRowTarget = iRowTarget   1
      count = count   1
    End If
  End If
If cell.Value = "Fælles" Or cell.Value = "Lagt Ud" Then
 wsSource.Rows(i).Columns("A:H").Font.Bold = True
End If
End With

Leave a Reply

Your email address will not be published. Required fields are marked *