VBA kopiere tekst i farver til anden celle
Hejsa,Jeg ønsker at kopiere tekst fra et ark til et andet, men ønsker at have tekstfarven med. Teksten kan være i flere farver i samme celle.
Har nedenstående kode til at overføre.
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim LR1 As Long, LR2 As Long, LR3 As Long, LR4 As Long, n As Long, i As Long, b As Long, Lastrow As Long
Application.ScreenUpdating = False
Set ws1 = Sheets("Kalk")
Set ws2 = Sheets("Tilbud dansk")
Set ws3 = Sheets("Tilbud Engelsk")
Worksheets("Tilbud dansk").Unprotect
Worksheets("Tilbud engelsk").Unprotect
ws2.Range("A106:A" & Rows.Count).ClearContents
ws2.Range("B106:B" & Rows.Count).ClearContents
ws2.Range("C106:C" & Rows.Count).ClearContents
ws2.Range("D106:D" & Rows.Count).ClearContents
ws2.Cells.Borders.LineStyle = xlLineStyleNone
LR1 = ws1.Range("B" & Rows.Count).End(xlUp).Row
ActiveSheet.Unprotect
LR2 = 106
For i = 20 To LR1
If ws1.Range("B" & i).Value = ("TEKST") And ws1.Range("M" & i).Value = ("JA") Then
ws2.Cells(LR2, "A").Value = ws1.Cells(i, "A").Value
ws2.Cells(LR2, "A").Font.FontStyle = "Calibri"
ws2.Cells(LR2, "A").BorderAround xlContinuous
ws2.Cells(LR2, "A").Font.Size = 12
ws2.Cells(LR2, "A").Font.Color = HVAD SKAL DER STÅ HER
ws2.Cells(LR2, "B").Value = ws1.Cells(i, "D").Value
ws2.Cells(LR2, "B").Font.FontStyle = "Calibri"
ws2.Cells(LR2, "B").BorderAround xlContinuous
ws2.Cells(LR2, "B").Font.Size = 12
ws2.Cells(LR2, "C").Value = ws1.Cells(i, "AA").Value
ws2.Cells(LR2, "C").Font.FontStyle = "Calibri"
ws2.Cells(LR2, "C").BorderAround xlContinuous
ws2.Cells(LR2, "C").NumberFormat = "#,##0"
ws2.Cells(LR2, "C").Font.Size = 12
ws2.Cells(LR2, "D").Value = ws1.Cells(i, "AA").Value
ws2.Cells(LR2, "D").Font.FontStyle = "Calibri"
ws2.Cells(LR2, "D").BorderAround xlContinuous
ws2.Cells(LR2, "D").NumberFormat = "#,##0.00"
ws2.Cells(LR2, "D").Font.Size = 12
LR2 = LR2 + 1
'End If
ElseIf ws1.Range("B" & i).Value = "JA" Then
ws2.Cells(LR2, "A").Value = ws1.Cells(i, "A").Value
ws2.Cells(LR2, "A").BorderAround xlContinuous
ws2.Cells(LR2, "A").Font.Size = 12
ws2.Cells(LR2, "A").Font.FontStyle = "Calibri"
ws2.Cells(LR2, "B").Value = ws1.Cells(i, "D").Value
ws2.Cells(LR2, "B").BorderAround xlContinuous
ws2.Cells(LR2, "B").Font.Size = 12
ws2.Cells(LR2, "B").Font.FontStyle = "Calibri"
ws2.Cells(LR2, "C").Value = ws1.Cells(i, "R").Value
ws2.Cells(LR2, "C").BorderAround xlContinuous
ws2.Cells(LR2, "C").NumberFormat = "#,##0"
ws2.Cells(LR2, "C").Font.Size = 12
ws2.Cells(LR2, "C").Font.FontStyle = "Calibri"
ws2.Cells(LR2, "D").Value = ws1.Cells(i, "Q").Value
ws2.Cells(LR2, "D").BorderAround xlContinuous
ws2.Cells(LR2, "D").NumberFormat = "#,##0.00"
ws2.Cells(LR2, "D").Font.Size = 12
ws2.Cells(LR2, "D").Font.FontStyle = "Calibri"
LR2 = LR2 + 1
End If
Next i