View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
[email protected] mdupris@hotmail.com is offline
external usenet poster
 
Posts: 27
Default copy and insert cells with macro

Tim,

The first part could be handled with the following code. I'm
confused about the "copy the formulas from G2:L2 to G1:L1 of the same
worksheet" part, though.

= Marchand =

Sub copyTheOnes()

Dim iRow As Integer
Dim iDestRowOffset As Integer

iDestRowOffset = 1
For iRow = 0 To 499
If Worksheets("Sheet1").Range("F1").Offset(iRow, 0).Value = 1
Then
Worksheets("Sheet2").Rows(iDestRowOffset).Insert
Shift:=xlDown

' The '13' in the next row extends the selection to column
'R'
Worksheets("Sheet1").Range("F1").Offset(iRow, 0).Resize(1,
13).Copy
Worksheets("Sheet2").Range("F1").Offset(iDestRowOf fset -
1, 0).PasteSpecial Paste:=xlPasteValues
iDestRowOffset = iDestRowOffset + 1
End If
Next iRow

End Sub

= Marchand =


On Feb 1, 7:03 pm, Tim wrote:
Hi All,

On Sheet1 is a range F1:R500. In some of the cells in column R is number
"1". What I need is to create a macro which will do the next: for every row
in range F1:R500 if the cell in column R is 1, copy cells F:R, then go to
Sheet2, insert a row, paste copied VALUES from Sheet1 in cell F1 of Sheet2
and copy the formulas from G2:L2 to G1:L1 of the same worksheet.
Any Help is highly appreciated.

Tim