1

How do I get the format and fill of a cell as well as values? I am transferring some data from one work sheet into another and need the formats but this code only takes the values. Any suggestions please?

Dim i As Integer
Dim j As Integer
Dim r As Integer
Dim l As Integer
Dim c As Integer

r = 2 'row No to start at on original data
l = 2 'row to start at for Mitigation

Sheets(2).Activate
Range("D2").Select
j = 2 ' row

Do Until IsEmpty(ActiveCell)  ' Set Do loop to stop when last row is reached.
    c = 4 ' column
    Do Until IsEmpty(ActiveCell)  ' Set Do loop to stop when an empty cell is reached.
        Sheets(6).Cells(l, 3) = Sheets(2).Cells(j, c) 'Description
        Sheets(6).Cells(l, 4) = Sheets(2).Cells(j, 1) 'H ID
        Sheets(6).Cells(l, 5) = Sheets(2).Cells(j, 2) 'S ID
        ActiveCell.Offset(0, 1).Select
        c = c + 1
        l = l + 1
    Loop
    r = r + 1
    j = j + 1
    ActiveCell.Offset(1, 4 - c).Select
Loop
Tom
  • 9,725
  • 3
  • 31
  • 48
Dawn
  • 33
  • 3

1 Answers1

0

you might try to do a copy/paste:

Sheets(2).cells(j, c).Copy Destination:=Sheets(6).Cells(l, 3)

This code would copy the cell in row "j" and column "c" on sheet 2, and paste it to sheet 6, row "l" column "3"

ChipperG
  • 64
  • 1
  • 5