LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default HELP! - Can't Copy Cells With VBA

I want to copy a cell from a closed workbook. I have a command button that
opens a workbook as a variable. The workbook opens fine, but I get errors
when it tries to copy the cell. It seems that it's not recognizing the
workbook variable as a workbook. I tried a number of different statements
and nothing seems to work. I'm not sure what's wrong. Any thoughts?
Thanks in advance
Todd


Private Sub CommandButton3_Click()

Dim FName As Variant
Dim WB As Workbook
FName = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),
*.xls", Title:="Please select a file")
If FName = False Then
Exit Sub
End If
Set WB = Workbooks.Open(FName)

WB.Worksheets("Sheet1").Range("C4").Copy _
Destination:=Worksheets("Sheet2").Range("E5")

WB.Close savechanges:=False
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Visible Cells in Sheet with Merged and Hidden Cells rtwiss Excel Discussion (Misc queries) 5 April 25th 23 09:08 AM
How can I copy big ranges of cells without drag or copy/paste? Ricardo Julio Excel Discussion (Misc queries) 3 March 23rd 10 02:38 PM
Copy and paste versus copy and insert copied cells Alana New Users to Excel 1 September 28th 07 08:58 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
Copy data into cells until changes trigger new copy mdeanda Excel Programming 2 April 25th 05 01:32 PM


All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"