Hi Tim,
I used a MsgBox in my code merely to give you visual confirmation that the
correct value had been assigned to the i variable. It serves no other
purpose here and can be deleted.
Whilst I do not know the layout or structure of your workbooks and data.,
there are a number of syntax problems in your code. Additionally, you make
repeated selections/activations. These are rarely necessary.
Revising your code to deal with these issues, we have:
Sub Atester()
Dim sStr As String
Dim pos As Long
Dim i As Long
Dim j As Long
sStr = Sheets("current sheet").Range("J2").Value
pos = InStrRev(sStr, "-")
i = Mid(sStr, pos + 1) + 1
j = i - 1
Workbooks("LL-CP-j.xls").Sheets("SheetYYY"). _
Range("F3:H3").Copy
Workbooks("Completions LL Register 2004-09-030.xls"). _
Sheets("SheetXXX").Range("F" & i). _
PasteSpecial Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
End Sub
You need to replace SheetXXX and SheetYYY with the appropriate sheet names.
Also, do you really have a workshheet named "Current Sheet"? If you do,
fine. If, however, you are endeavouring to reference the active worksheet,
replace the line:
sStr = Sheets("current sheet").Range("J2").Value
with
sStr = ActiveSheet.Range("J2").Value
Lastly, You have introduced a new variable j but there appears to be no use
made of the variable.