View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Lookin cell values, copy a range and paste it

Hi Kevin

This shoud do it. Just notice that it will fail if "performance" is
found below row 65260, but maybe it's not a problem?

Sub Kevin()

Set found = Range("A1:A65536").Find(What:="performance",
After:=Range("A1"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If Not found Is Nothing Then
found.Resize(277, 1).Copy Destination:=Range("B1")
fCell = found.Address
Else
msg = MsgBox("Performance was not found!", vbExclamation)
Exit Sub
End If
off = 1
Set Target = Range(found.Address)
Do
Set found = Range("A1:A65536").FindNext(After:=Target)
If found.Address = fCell Then Exit Do
found.Resize(277, 1).Copy Destination:=Range("B1").Offset(0, off)
off = off + 1
Set Target = Range(found.Address)
Loop

End Sub

Regards,
Per

On 29 Okt., 00:26, wrote:
HI again group,

I am almost breaking my head to successfully write a macro for what I
am trying to accomplish...

1. Look in range A1:A65536.
2. IF any cell value in range A1:A65536 starts with the word
"perform", THEN FIND that cell and copy it and the next 276 values and
paste in the adjacent columns..

Example:
Assuming cell A6 has the word "performance 1", cell A400 has the word
"performance 2" and cell A878 has the word "perform23", then, copy
cells A6 thru A281 (interval - 276) and paste in cell B1.
Copy cell A400 thru A675 (interval - 276) and paste in cell C1.
Copy cell 878 thru 1153 (interval - 276) and paste in cell D1.
etc...

Any help would be greatly helpful.. I am really blowing my mind here
to get this working.

Kevin