Consulting

Results 1 to 3 of 3

Thread: Macro to find a word and select a range based in their position

  1. #1
    VBAX Newbie
    Joined
    Aug 2013
    Posts
    2
    Location

    Macro to find a word and select a range based in their position

    I have a format that is 62 rows by 11 columns and in the same sheet and are placed one above the other. Each format has an identifier like "Eco 2" and their position in in the first column, row number 4 of each format.

    I want a macro that find for example "Eco 4". If the Eco 4 are in the cell A314 the macro should select the range A311:K372, then copy and paste in other workbook, each format in different sheet of the new workbook. Is possible that I can found Eco 4 more than one time in the original workbook.

    I want consolidate all Eco 4 formats in a new worbook in differents sheets.


    Thanks experts.

    In the attached file the identifier is "Pozo: XXXX" try searching CAFETO-20 (DES)
    Attached Files Attached Files
    Last edited by jongova; 09-02-2013 at 06:16 PM. Reason: Upload a file

  2. #2
    Can you upload a copy of your workbook so that we can see were working with It's easier that way, as we can code and debug on a 'true' example

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,647
    sub M_snb()
      for j =1 to sheets("reportd").usedrange.rows.count\62
        sheets("reportd").usedrange.find("CAFETO-20",sheets("reportd").cells(62*(j-1)+1,1),xlvalues,xlpart).offset(-3).resize(62,11).copy sheets("CAFETO-20").cells(rows.count,1).end(xlup).offset(2)
      next
    End Sub
    or

    Sub M_snb()
        With Sheets("reportd").UsedRange
           .AutoFilter 1, "*CAFETO-20*"
           c00 = .Columns(1).SpecialCells(12).Address
           .AutoFilter
    
           For Each cl In Range(c00)
              If cl.Row > 1 Then cl.Offset(-3).Resize(62, 11).Copy Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(2)
           Next
        End With
    End Sub
    Last edited by snb; 09-03-2013 at 03:31 AM.

Tags for this Thread

Posting Permissions

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