+ Reply to Thread
Results 1 to 5 of 5

VBA: copy by address filtered selection of cells

Hybrid View

  1. #1
    Registered User
    Join Date
    12-16-2011
    Location
    IL
    MS-Off Ver
    Excel 2007
    Posts
    3

    VBA: copy by address filtered selection of cells

    hi
    I am trying to copy a group of cells (a selection)from one sheet ("SOURCE")
    to another ("DEST"). Before I copy I am doing a filter (using AutoFilter)for that cells, so only rows start with column "YES" will be copied.


    Sub Build()

    Application.ScreenUpdating = False

    Worksheets("SOURCE").Activate

    [SOURCE!B3:D6].AutoFilter Field:=1, Criteria1:="YES"

    ' copy by value
    '[SOURCE!B3:D6].Copy Sheets("DEST").[A1]

    ' copy by address
    Range("SOURCE!B3:D6").Select
    [DEST!A1:C4].Formula = "=SOURCE!" & ActiveCell.Address(0, 0)

    [SOURCE!B3:D6].AutoFilter

    Application.ScreenUpdating = True

    End Sub

    If I copy the cells by value (using copy method) it's OK - the filter works.
    But I want to copy the cells by reference (address) so change in the SOURCE
    will affect the cell in the DEST. Here the filter is ignored. What can I do
    to copy cells by reference and still using the filter? ?
    Tnx
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: VBA: copy by address filtered selection of cells

    Your requirement is not very clear. Maybe you could try explaining again?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    12-16-2011
    Location
    IL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA: copy by address filtered selection of cells

    Quote Originally Posted by arlu1201 View Post
    Your requirement is not very clear. Maybe you could try explaining again?
    I am trying to copy the address of rows that match the criteria of "YES".
    Copy the values of cells that match the criteria works well, but I want to copy address of those cells that match the criteria.

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: VBA: copy by address filtered selection of cells

    Not sure what this is exactly what you want, but try.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-16-2011
    Location
    IL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA: copy by address filtered selection of cells

    well in general it works, but:
    First, its a complicated solution. I thought about something more simple since I need to duplicate this code to some other sheets I have.
    Second, this solution is copying also the "YES" column, but I don't need to copy it. of course I can change the indices in the array to accomplish it , however , to debug such code , now or in the future, is a very difficult mission to me.
    thanks anyway

+ 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