View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
AB[_2_] AB[_2_] is offline
external usenet poster
 
Posts: 236
Default Should be easy...what's missing?

You actually don't need to select a cell to copy/paste - you can just
refference them.
Also c.address retruns a string and not the cell (range) object itself
- and you can't select a string (you can select a range).
Also be careful when using ActiveSheet - be sure you really want to
paste into the ACTIVE sheet and not a specific one - e.g., the code
below would paste into Sheet3 as oppose to ActiveSheet that you had.
Amend as necessary.

Try this:

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Copy destination:=
Worksheets("Sheet3").cells(c.row, "A")
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


On Mar 29, 2:47*pm, MovingBeyondtheRecordButton
.com wrote:
Code doesn't work due to error on line: *c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
* * Set c = .Find(F.Value, LookIn:=xlValues)
* * If Not c Is Nothing Then
* * * * firstAddress = c.Address
* * * * Do
* * * * * * Worksheets("Sheet3").Range("Q2:V2").Select
* * * * * * Application.CutCopyMode = False
* * * * * * Selection.Copy
* * * * * * c.Address.Select
* * * * * * ActiveCell.Offset(0, -6).Range("A1").Select
* * * * * * ActiveSheet.Paste
* * * * * * Set c = .FindNext(c)
* * * * Loop While Not c Is Nothing And c.Address < firstAddress
* * End If
* * End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into columns
A through F (in the same row as the cell that was just found in .Find)