Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Copy from one workbook to another

I am trying to create a macro that is asigned to a button. When you
press the button I want it to let you navigate to the workbook you
want, then when you open the desired workbook it copies and paste
specials (values and number formats) all of sheet 1 from the workbook
you navigated to into sheet 1 of the workbook that the button is in.
Any help with the code to at least point me in the right direction
would be greatly appreciated.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Copy from one workbook to another

Put the following in a regular Module.

Public Sub CopySheet1()
Dim str1 As String
Dim iRtn As Integer
Dim wb As Workbook
Dim rng As Range

iRtn = MsgBox("Are you sure you want to copy to a non-empty sheet?",
vbYesNo)
If iRtn = vbNo Then Exit Sub
str1 = Application.GetOpenFilename("Excel files, *.xls")
Set wb = Workbooks.Open(str1)
Set rng = wb.Sheets("Sheet1").UsedRange
rng.Copy
ThisWorkbook.Activate
Sheets("Sheet1").Activate
Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
wb.Close
End Sub

Hth,
Merjet

Reply
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
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Excel-how to link source workbook to copy of destination workbook D Lynn Excel Worksheet Functions 1 May 29th 08 05:36 PM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM


All times are GMT +1. The time now is 02:39 PM.

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

About Us

"It's about Microsoft Excel"