+ Reply to Thread
Results 1 to 1 of 1

Macro to search sheet 1 for value and insert entire row from sheet 2

  1. #1
    Registered User
    Join Date
    12-09-2011
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    1

    Macro to search sheet 1 for value and insert entire row from sheet 2

    Hey gang,

    I am new to excel macros. I have plenty of vba experience so I think we could do this easily.

    I have a spreadsheet with several tabs. the overall goal is this

    Search for values in the Sheet called "BOM" in the "O" column. If the O column says "D" then we need to go to the sheet called BOM HEADERS and copy row 9 and 10 and insert them back onto the BOM sheet right above where you found the "D" in column "O". Then i need to search BOM sheet for "p". if found insert the rows 34 and 35 on sheet "BOM HEADERS" back onto sheet "BOM" above the first instance of a row that has "p" in the "O" column. I am basically wanting to take these headers and paste them back on the first sheet so i can have a pretty looking spreadsheet. it is too manual now and wastes lots of time. Once i have all my headers in place i want to copy all the values from sheet "BOM" to sheet "PACKING LIST". once i have done this i want to delete all the rows that have a column "A" value containing a decimal. So it will copy the values from sheet "BOM" and past them onto sheet "PACKING LIST" and then on sheet "PACKING LIST" delete all the rows that have a value in the first colum like 2.1. so all the packing list will show is whole number rows. I hope this is descriptive enough. I will paste the code i have so far.

    it wont let me attach the spreadsheet. keep getting an database error
    Dim LSearchRow As Integer


    'Start search in column 15

    LSearchRow = 1







    While Len(Range("A" & CStr(LSearchRow)).Value) > 0
    If Range("O" & CStr(LSearchRow)).Value = "D" Then




    'Select DuctWork Header and copy
    Sheets("BOM HEADERS").Select
    Rows(9).Select
    Selection.Copy

    'Paste into bom
    Sheets("BOM").Select
    Rows(CStr(LSearchRow)).Select
    ActiveSheet.Paste





    'Move counter to next row


    'Go back to Sheet1 to continue searching
    Sheets("BOM").Select

    End If

    LSearchRow = LSearchRow + 1

    Wend
    Last edited by mtlong88; 12-09-2011 at 01:22 PM. Reason: upload

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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