Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook | Excel Worksheet Functions | |||
Excel-how to link source workbook to copy of destination workbook | Excel Worksheet Functions | |||
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook | Excel Programming | |||
Copy a range of cells in an unopened workbook and paste it to the current workbook | Excel Programming |