• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

find and copy

I am looking for some vba code that will find the word Stock the copy all cells below that contain data and then to the right

i.e. It cell A5 contains Stock and all cells down to A16 have data and cells right to F15 have data copy A5:A16

Thanks
0
Jagwarman
Asked:
Jagwarman
  • 2
1 Solution
 
Rgonzo1971Commented:
HI,

I don't understand where you want to paste them

Sub Makro1()
    Set FoundCell = Cells.Find(What:="Stock", After:=Range("A1"), LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)
    Range(FoundCell, Cells(FoundCell.End(xlDown).Row, FoundCell.End(xlToRight).Column)).Copy
 
End Sub

Open in new window

Regards
0
 
JagwarmanAuthor Commented:
Rgonzo1971 where I paste it to will vary but your solution works great. Thanks
0
 
JagwarmanAuthor Commented:
Rgonzo1971

Nothing is ever simple is it :-)

I have used this on another file and it is not doing what I thought it was going to do.

The file I am now working on has the same word in A1 G1 and H1 so it goes to G1 and copies from there.

Probably my fault, I need it to start from the first occurance [in this case A1] so if A1 did not have the the word I am looking for and the first occurance was G1 that would be ok.

Can you make the amendment for me pleae.

Many thanks
Regards
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now