+ Reply to Thread
Results 1 to 3 of 3

Add new rows after finding a specific value using vba

  1. #1
    Registered User
    Join Date
    05-08-2019
    Location
    Stoke
    MS-Off Ver
    2016
    Posts
    2

    Add new rows after finding a specific value using vba

    Hello everyone,

    This is the first time I am posting in here if anyone can help me.

    I want to do the below task.

    In my excel sheet I want to find a specific text value (eg: Formula 1) then need to add 10 rows above that row(above the cell with Formula 1) and then need to paste some values in an another sheet (in sheet 2, A1:A10). How can I do this using vba mcaro?

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Add new rows after finding a specific value using vba

    Hi !

    As a starter : just activate the Macro recorder & operate manually then you will get your own free code !

  3. #3
    Registered User
    Join Date
    05-08-2019
    Location
    Stoke
    MS-Off Ver
    2016
    Posts
    2

    Re: Add new rows after finding a specific value using vba

    Thank you very much for your suggestion. I have done what you suggested before but the problem is I cant use the record vab again because ( formula 1) can be anywhere in the sheet and the recorded macro will insert rows every time with respect to Rows("11:20") which is related to the early record. This was the recorded macro.

    Sub Macro1()

    '

    ' Macro1 Macro

    '

    '
    Cells.Find(What:="Function 1", After:=ActiveCell, LookIn:=xlFormulas, _

    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _

    MatchCase:=False, SearchFormat:=False).Activate


    Rows("11:20").Select

    Range("A20").Activate

    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

    Sheets("Sheet2").Select

    Range("A14:A23").Select

    Selection.Copy

    Sheets("Sheet1").Select

    Range("A21").Select

    ActiveSheet.Paste

    End Sub



    Any suggestion is kindly appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. finding a specific format and open the rows so that the full text displays
    By Louisa Venter in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-21-2015, 04:32 PM
  2. Finding specific text, remove a row and add two rows inbetween
    By Louisa Venter in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 10-21-2015, 07:11 AM
  3. Finding specific text in a column and deleting rows
    By VKS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2013, 04:09 PM
  4. [SOLVED] Finding duplication in specific rows of a column
    By mrjinx007 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-30-2013, 12:08 PM
  5. [SOLVED] Complex Data Search - finding consecutive rows with a specific pattern
    By multiades in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-15-2012, 07:47 PM
  6. [SOLVED] Re: finding the number of rows and the first row with a specific value
    By rjamison in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2005, 08:05 PM
  7. [SOLVED] finding the number of rows and the first row with a specific value
    By Bruce Bowler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2005, 12:06 PM

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