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!
Bookmarks