+ Reply to Thread
Results 1 to 3 of 3

Conditional Copy/Paste Dynamic Range

Hybrid View

  1. #1
    Registered User
    Join Date
    11-10-2014
    Location
    DC
    MS-Off Ver
    2010
    Posts
    3

    Conditional Copy/Paste Dynamic Range

    Hi, I'm new to VBA, so any help would be appreciated. I'm trying to move values from 2 separate workbooks--'CT' to 'FAWB'--given certain conditions. When i run the macro below, Excel doesn't prompt an error message, but there are no values moving from one workbook to the next, so I'm not sure what the issue is.

    Here are the events that need to take place:
    If:
    condition 1: Value in column H of CT.SPview= 'FA'
    condition 2: Value in column B of CT.SPview doesn't appear in column B of FAWB.IRSheet.
    Then:
    copy paste values where conditions 1 and 2 are met into next available row of FAWB.IRSheet.

    Below is the code that was used.
    Sub Main()
    
    'declaring workbook/worksheet variables.
    Dim IRSheet As Worksheet
    Dim SPview As Worksheet
    Set FAWB = Workbooks.Open("C:\Users\dyoo\Desktop\Assignment Tool 1-2-15\FA_IRWB.xlsm")
    Set CT = Workbooks.Open("C:\Users\dyoo\Desktop\Assignment Tool 1-2-15\CopyCentralTracking_11-19.xlsm")
    
    
    Set IRSheet = FAWB.Worksheets("IRSheet")
    Set SPview = CT.Worksheets("Supervisor View")
    
    'declaring row/cell variables
    Dim CTrng As Range
    Dim IRrng As Range
    
    Dim CTCell As Range
    Dim IRCell
    
    Set IRrng = IRSheet.Range("A1").CurrentRegion.Select
    
    Set CTrng = SPview.Range("A1").CurrentRegion.Select
    
    Set CTCell = CTrng.Cells
    Set IRCell = IRrng.Cells
    
    For Each CTCell In CTrng
    If Range("H").Value = "FA" And Cells(CTCell, 2).Values <> Cells(IRCell, 2).Values Then
    CTCell.EntireRow.Copy Destination:=Workbooks("FAWB").Sheets("IRSheet").Range("A65536").End(xlUp).Offset(1, 0).Select
        End If
    Next CTCell
    End Sub
    Thanks in advance for the help and patience!
    Last edited by dyoo; 01-04-2015 at 10:39 AM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,603

    Re: Conditional Copy/Paste Dynamic Range

    Hi,
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Registered User
    Join Date
    11-10-2014
    Location
    DC
    MS-Off Ver
    2010
    Posts
    3

    Re: Conditional Copy/Paste Dynamic Range

    Hi, I made the requested changes. If any one out there has tips/nudges in the right direction, it would be super helpful and very much appreciated. Thanks again for the help.
    Last edited by dyoo; 01-05-2015 at 08:11 PM.

+ 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. [SOLVED] Copy/Paste Dynamic Range
    By RedStick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-28-2014, 03:38 PM
  2. [SOLVED] Copy and Paste Dynamic Range
    By VKS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2013, 11:14 AM
  3. Dynamic offset range copy/paste
    By elxan0611 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2010, 04:45 AM
  4. Copy dynamic range from previous sheet and paste after last used row in a range
    By Mistweaver in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-04-2010, 06:24 PM
  5. Copy and paste dynamic range
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-16-2010, 09:42 AM

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