Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2008, 06:22 PM
Authorized User
 
Join Date: Jun 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mona_upm84
Default Copy from cell A3 workbookA into cell A3 workbookB

Hi all,

I need some help... Let say from a userform, there is a comboBox1 list all .xls files in My Document. As soon as the user choose one of the list and click Submit, userform closed and data from cell A3 in selected .xls copied into A3 of the current workbook, Sheet1.

How can i do that? I tried many ways, but failed. Hope somebody can help me....

 
Old September 5th, 2008, 01:31 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Mona

Here is a hint.

Code:
Private Sub CommandButton1_Click()

Dim sWB As String
Dim sPath As String
Dim oWB1 As Workbook
Dim oWB2 As Workbook
 
 
sPath = "c:\temp\"
sWB = ComboBox1.Value

Unload Me

Set oWB1 = ActiveWorkbook
Set oWB2 = Workbooks.Open(sPath & sWB)

oWB1.Sheets(1).Range("A3").Value = oWB2.Sheets(1).Range("A3").Value

oWB2.Close (False)

End Sub
Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy cell into userform? Cabbage VB How-To 2 April 29th, 2008 07:04 AM
copy columns based on cell values EricB123 Excel VBA 0 December 18th, 2007 12:51 AM
Copy data into cell by cell zone Excel VBA 2 September 4th, 2007 11:50 AM
I need to refer a cell within a cell like =RC[ RC2 chakravarthi_os Excel VBA 1 September 24th, 2006 08:19 AM
Lose cell Text when editing cell in VSFlexGrid 6 bobcratchet VB How-To 0 July 30th, 2004 09:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.