Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data not copying in EXCEL 1

Status
Not open for further replies.

Grumbledook

Technical User
Dec 13, 2002
45
0
0
GB
I am trying to code in VBA a simple routine to copy selected cells in one workbook to selected cells in another. The routine is working but the copied data is displayed as #REF instead of numbers. Both Workbooks are formatted exactly the same. The Code is contained in a user form in Target Workbook. The user form asks for specific data and then opens the source workbook using user inputted data.

CODE:

Private Sub CommandButton1_Click()

'Open source workbook

Workbooks.Open Filename:="" & Collartext.Text & _ Surnametext.Text & Monthtext.Text & Yeartext.Text

'Select range and paste to target workbook
Call CopyRange

Application.CutCopyMode = False
End Sub

Sub CopyRange()
'Gets selected range from Source Workbook
Sheets("Sheet1").Activate
Range("E25:I25").Select
Selection.Copy

'Activates target workbook
ThisWorkbook.Activate
ActiveSheet.Range("D3:H3").Select
Selection.Paste

End Sub

Any ideas?

G.
 


Hi,
Code:
...
Selection.PasteSpecial xlValues


Skip,
[sub]
[glasses] [red]Be Advised![/red] A man who jumps from a bridge in Paris, is…
INSANE! [tongue][/sub]
 
Thanks Skip .... it's always something so simple! Have a star.

Regards

G.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top