Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Coping Contents of one Sheet into Another Workbook
I have a need to build a Macro that will take an excel file (Which the
user specifies) and copies the contents of the second sheet (With a specific name) into another workbook putting specific cells in specific places in the second workbook. Then I need it to rename the file so we know that the file has been input. I'm not even sure where to start, I'm sure I can get the pieces for the copying and pasting, but how to handle the file and such is going to be a bit more difficult for me. Can anyone lend a hand in leading me in the right direction? TIA J. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Coping Contents of one Sheet into Another Workbook
Hi
Try the following routines. Function OpenWorkbook(ByRef wb As Workbook) As Boolean Dim v As Variant On Error GoTo OpenWorkbookError v = Application.GetOpenFilename(FileFilter:="(*.xls),* .xls") If TypeName(v) = "Boolean" Then 'User Cancelled GoTo OpenWorkbookError Else Set wb = Application.Workbooks.Open(v) End If OpenWorkbook = True Exit Function OpenWorkbookError: OpenWorkbook = False End Function Function CopyWorkbook() Dim wb As Workbook Dim wbNew As Workbook Dim wsNew As Worksheet If OpenWorkbook(wb) Then 'do something Set wbNew = Workbooks.Add 'The worksheet you want to copy will replace 'abc below. wb.Worksheets("abc").Copy Befo=wbNew.Worksheets(1) Set wsNew = ActiveSheet 'To copy specific cells to the new worksheet created 'in the new workbook(now called wsNew) you do the following wsNew.Cells(1, 1).Value = wb.Worksheets("pqr").Cells(1, 1).Value 'do other processing wbNew.Close SaveChanges:=True wb.Close SaveChanges:=True End If End Function Alok "Egon" wrote: I have a need to build a Macro that will take an excel file (Which the user specifies) and copies the contents of the second sheet (With a specific name) into another workbook putting specific cells in specific places in the second workbook. Then I need it to rename the file so we know that the file has been input. I'm not even sure where to start, I'm sure I can get the pieces for the copying and pasting, but how to handle the file and such is going to be a bit more difficult for me. Can anyone lend a hand in leading me in the right direction? TIA J. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Coping Contents of one Sheet into Another Workbook
I think I get part of what you are doing here, the only problem is that
the form was created by someone else (The excel worksheet that I'm copying FROM) and I don't want the format of the cells, I just need the data IN the cells. But I think I can get that if I can get it opened and Closed. Let me try this and see how it goes. Thanks a ton. J |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
WHY DOES COPING FROM SHEET TO SHEET INCREASE SIZE DRAMATICALLY? | Excel Discussion (Misc queries) | |||
Returning contents of a cell in another sheet in same workbook | Excel Discussion (Misc queries) | |||
Table of Contents Sheet in Workbook | Links and Linking in Excel | |||
Find Cell Contents on Another Sheet in Workbook | Excel Programming | |||
Coping a sheet | Excel Programming |