Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble copying a range instead of entire row

Status
Not open for further replies.

althea

MIS
Oct 15, 2001
134
US
I have the following code but I need to modify it to only copy the first 16 columns, not the entire row of data. Any ideas?

Sub CopyData()
Dim PRange As Range
Dim Rfinal As Range
Dim Prow As Range
Dim RowNum As Long

'PRange is is from P1 to last cell in Column P
Sheets("Deal Entry").Activate
Set PRange = Worksheets("Deal Entry").Range(cells(1, 16), cells(65536, 16).End(xlUp))
PRange.Select
With PRange
Set c = .Find(Range("A1").Value, after:=Range("P1"), searchdirection:=xlPrevious)
lRow = 187
If Not c Is Nothing Then
firstrow = c.Row
RowString = c.Row & ":" & c.Row

Do
Sheets("Reports").Rows(lRow) = Sheets("Deal Entry").Rows(c.Row).Value
lRow = lRow + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And firstrow <> c.Row

Range(&quot;p8&quot;).Select
End If
Sheets(&quot;Reports&quot;).Activate
Range(&quot;a187&quot;).Select
End With

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top