Following jpw, it would be nice to encapsulate its solution in a small routine to save on having a lot of lines of code:
Private Sub CommandButton1_Click() Dim i As Integer Dim a As Integer a = 15 For i = 11 To 32 If Worksheets(1).Cells(i, 3) <> "" Then call copValuesAndFormat(i,3,a,15) call copValuesAndFormat(i,5,a,17) call copValuesAndFormat(i,6,a,18) call copValuesAndFormat(i,7,a,19) call copValuesAndFormat(i,8,a,20) call copValuesAndFormat(i,9,a,21) a = a + 1 End If Next i end sub sub copValuesAndFormat(x1 as integer, y1 as integer, x2 as integer, y2 as integer) Worksheets(1).Cells(x1, y1).Copy Worksheets(2).Cells(x2, y2).PasteSpecial Paste:=xlPasteFormats Worksheets(2).Cells(x2, y2).PasteSpecial Paste:=xlPasteValues end sub
(I do not have Excel at the current location, so please excuse the errors if they are not tested)
whytheq
source share