Copy & paste special

P

pkeegs

I have the following section of code copied from another macro. The only
difference to the macro I have copied is the "ActiveCell.Offset(0,76).Select"
code. The Macro finds the correct cell but then stops at the PasteSpecial.
"CopyEvaluate" is a 4 cell range being copied into a location in another
sheet "Database". Has anyone got any thoughts as to why the Macro will not
paste when it works perfectly in the original macro?

Range("CopyEvaluate").Select
Selection.Copy
Sheets("Database").Select

Range("FormNumber").Select
Do Until ActiveCell = Range("B2").Value
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell.Offset(0, 76).Select

Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
 
J

JLGWhiz

Not sure what the problem was, but this minor modification cured it.

Sub fdk()
Range("A1:d1").Select
Selection.Copy
Sheets("Sheet2").Select

Range("B3").Select
Do Until ActiveCell = Range("B2").Value
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Offset(0, 76).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats _
, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub

I suggest you learn to write your code without using the Select method. It
is much more effficient.
 
J

JLGWhiz

Sorry, should have gone back to your original code. Try this.

Range("CopyEvaluate").Select
Selection.Copy
Sheets("Database").Select

Range("FormNumber").Select
Do Until ActiveCell = Range("B2").Value
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell.Offset(0, 76).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats _
, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top