+ Reply to Thread
Results 1 to 2 of 2

macro vba to select ranges to copy other worksheets (loop)

Hybrid View

aaaaa34 macro vba to select ranges to... 09-02-2024, 09:50 AM
Artik Re: macro vba to select... 09-03-2024, 07:14 PM
  1. #1
    Forum Contributor aaaaa34's Avatar
    Join Date
    12-25-2013
    Location
    Istanbul
    MS-Off Ver
    Office365
    Posts
    388

    macro vba to select ranges to copy other worksheets (loop)

    Hello everybody,
    I hope you all doing well guys.

    I'd like to ask your help for macro vba to select cells between G and S columns continously till last row
    I mean code will continously select ranges G2:S3 , G5:S8 , G10:S15 , G17:S17 , G19:S25 , stop
    But, I want macro start to run selecting range from next range which cell I click in the "fixture" worksheet.

    For example:
    i selected cell P5 or M6:R7 range.
    when I run macro, it will start with selecting selecting G10:S15 , then G17:S17 , then G19:S25 , stop.

    I need this macro part for adding into another macro which copying these ranges to other worksheet.
    so you don't need to add copy+paste section.

    Pls have a look into attached workbook
    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,543

    Re: macro vba to select ranges to copy other worksheets (loop)

    Try. Without selecting. Without looping.
    Sub AAA()
        Dim wksS As Worksheet
        Dim wksT As Worksheet
        Dim LO As ListObject
        Dim lRow As Long
    
        Set wksS = Worksheets("fixture")
        Set wksT = Worksheets("output")
    
        Set LO = wksS.ListObjects(1)
    
        With wksT
            lRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1).Row
        End With
        
        On Error Resume Next
        wksS.ShowAllData
        On Error GoTo 0
        
        LO.Range.AutoFilter Field:=7, Criteria1:=">0", Operator:=xlAnd
    
        LO.DataBodyRange.Columns("G:S").Copy wksT.Cells(lRow, "A")
        LO.Range.AutoFilter Field:=7
    
    End Sub
    Artik

+ 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. Macro to open file, select tab, and copy 2 ranges.
    By germanVL in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-01-2020, 10:59 AM
  2. Excel VBA Loop Macro - Copy Different Ranges and Paste into Multiple Workbooks
    By Hoover5896 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2017, 08:47 PM
  3. Loop through worksheets and copy data ranges into one sheet
    By mcaballero in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2015, 04:44 PM
  4. macro to loop through table and copy values to multiple worksheets
    By The Fly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2015, 02:15 PM
  5. Replies: 0
    Last Post: 04-01-2014, 08:03 AM
  6. Replies: 0
    Last Post: 08-05-2013, 11:34 AM
  7. Loop command macro to copy data between worksheets
    By ThunderBuck in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-12-2009, 11:55 AM

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