Question Locked

VBA Excel Help

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am having trouble selecting a cell using VBA code so I can paste data from another application/workbook. I think its a downfall of VBA-Excel because I have had this trouble before. Below is my code. Does anyone know how to get around it.

Set MyXL = GetObject("C:\Documents and Settings\rimap\Desktop\NIMO PI\plugNchugNIMO.xls")

' Show Microsoft Excel through its Application property. Then
' show the actual window containing the file using the Windows
' collection of the MyXL object reference.
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
'Do manipulations of your file here.
MyXL.Activate
MyXL.Sheets("PIbatchPaste").Activate
MyXL.Sheets("PIBatchPaste").Cells.ClearContents

' this is where I have my trouble... it doesn't paste!
MyXL.ActiveSheet.Range("A1").Select
Selection.Paste

Thanks

3 replies

by sgt_shultz

I am no vb expert but your code looks incomplete to me. are you perhaps clearing the contents you wish to paste?

by jackofalltech

Instead of pasting the value, why not set it instead?

MyXL.ActiveSheet.Range("A1").Value = sMyValue

Ralph

This discussion is closed to new replies.