+ Reply to Thread
Results 1 to 9 of 9

trouble with vba code for Find, Insert copied cells and find next

  1. #1
    Registered User
    Join Date
    03-23-2012
    Location
    New Albany, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    5

    trouble with vba code for Find, Insert copied cells and find next

    So this is the code i have so far. what i am trying to do is in Column E find the Word Florida. Every time it finds the word florida i want it to insert 6 rows and paste the values from Cells AP1:AP6 in the inserted rows after florida. I want it to do this until they find the last Florida in the sheet. Any help would be appreciated

    Sub findinsertpaste()
    '
    ' findinsertpaste Macro
    '

    '
    Do while
    Columns("E:E").Select
    Selection.Find(What:="Florida", After:=ActiveCell, LookIn:=xlFormulas _
    , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    Selection.EntireRow.insert
    Selection.EntireRow.insert
    Selection.EntireRow.insert
    Selection.EntireRow.insert
    Selection.EntireRow.insert
    Selection.EntireRow.insert
    Application.CutCopyMode = False
    Range("AP1:AP6").Copy
    ActiveCell.PasteSpecial xlPasteValues

    Until Range("E:E") = " "

    End Sub

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,963

    Re: trouble with vba code for Find, Insert copied cells and find next

    Please wrap your code with code-tags:
    Rule #3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Select your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button).
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: trouble with vba code for Find, Insert copied cells and find next

    Does Column E have "Florida" anywhere in the first 6 Rows?
    If so, copying will not have the result you want.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,963

    Re: trouble with vba code for Find, Insert copied cells and find next

    @jolivanes: What kind of forum will we end up with when no one follows the rules? I asked for code tags and you should have waited for compliance.

  5. #5
    Registered User
    Join Date
    03-23-2012
    Location
    New Albany, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: trouble with vba code for Find, Insert copied cells and find next

    I apologize. i am new here. I read forum rule # 3 and don't quite understand. would you mind explaining what you mean by code tags? that way i know how to be compliant in the future. it would be greatly appreciated.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: trouble with vba code for Find, Insert copied cells and find next

    @protonLeah
    Apologies. Will wait next time.

    @jgelbach
    Have a look here.

    http://www.excelforum.com/misc.php?do=bbcode

    Close to the end under the header "Code"

  7. #7
    Registered User
    Join Date
    03-23-2012
    Location
    New Albany, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: trouble with vba code for Find, Insert copied cells and find next

    [QUOTE=jgelbach;2741542]So this is the code i have so far. what i am trying to do is in Column E find the Word Florida. Every time it finds the word florida i want it to insert 6 rows and paste the values from Cells AP1:AP6 in the inserted rows after florida. I want it to do this until they find the last Florida in the sheet. Any help would be appreciated

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: trouble with vba code for Find, Insert copied cells and find next

    Not a very sophisticated code.
    Hopefully someone will come by with a better code

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-23-2012
    Location
    New Albany, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: trouble with vba code for Find, Insert copied cells and find next

    thank you so kindly for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1