Hi,
I'm quite new to this so I'm struggling with putting something together and keep get a compile error saying - Compile error: Else without If
I want to reference something on one worksheet with another worksheet and if a match is found then a cell on the same row of the match is to be copied then pasted elsewhere on the row.
Example: look for a match between "B5" and "A7 to end of data in column" from 2 sheets.
When a match is found, copy from same row but different column of "B5" and paste it into the first blank cell of the same row but different column of "A7" (within a 3 cell range)
If no blanks, do nothing.
Move from "B5" to "B6" and repeat.
Code as below:
*************************************************************************** **************************
Sub Autocomp()
Dim refcit As Variant
Dim citrixm As Range
Dim citrix1 As Range
citrixm = Worksheets("Master").Range("A7").End(xlDown)
citrix1 = Worksheets("WI pull").Range("B5")
ActiveCell = citrix1
Do Until IsEmpty(citrix1) And IsEmpty(citrix1.Offset(1, 0))
refcit = Application.Match(citrix1, citrixm, 0)
If IsEmpty(Range("refcit").Offset(21, 0)) = True _Then Range("Worksheet.citrix1").Offset(2, 0).Copy Destination:=Range("refcit").Offset(21, 0)
ElseIf IsEmpty(Range("refcit").Offset(22, 0)) = True _
Then Range("Worksheet.citrix1").Offset(2, 0).Copy Destination:=Range("refcit").Offset(22, 0)
ElseIf IsEmpty(Range("refcit").Offset(23, 0)) = True _
Then Range("Worksheet.citrix1").Offset(2, 0).Copy Destination:=Range("refcit").Offset(23, 0)
Else
citrix1.Offset(1, 0).Select
End If
Loop
*************************************************************************** **************************
I've highlighted red the sections where it gives the error
Any help greatly appreciated