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

Hi,
If I automate the opening of another workbook what is the way to copy the
whole worksheet and paste it to the current workbook?
Or should this be done by importing.
I realise that the worksheet will be overwriten.
I am working on a VBA code to ask a question if the current workbook needs
updating and if yes, then another workbooks worksheet is added.
This will then allow me to copy and paste ranges from one sheet to another
and update records automatically. I figure this is the only way to do it as
to have both workbooks open and selectively cut and paste from one book to
the other is beyond me.
--
Regards
Bill
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Copy?import whole sheet from another workbook

The follwowing should work:

Sub Macro1()

Dim wsCurrent as Worksheet
Dim wbCopy as Workbook
Dim wbCurrent as Workbook
Dim x
Dim sYourFilename as String

x = MsgBox("Do You Wish to Update", vbYesNo, "Update?")
If x = vbYes Then
Set wbCurrent = ActiveWorkbook
Set wsCurrent = ActivveSheet

sYourFilename = "xxxxxxxx.xls" 'Replace with your filepath and
name

Workbooks.Open sYourFilename
Sheets("Sheet1").Activate 'Replace with your sheet
name
Cells.Select
Selection.Copy

wbCurrent.Activate
wsCurrent.Activate

Applicaiton.DisplayAlerts = False 'If you want to copy over any
existing data with no warning

ActiveSheet.Paste

wbCopy.Close
Application.DisplayAlerts = True

Set wbCurrent = Nothing
Set wbCopy = Nothing
Set wsCurrent = Nothing
End If

End Sub


"justagrunt" wrote in message
...
Hi,
If I automate the opening of another workbook what is the way to copy the
whole worksheet and paste it to the current workbook?
Or should this be done by importing.
I realise that the worksheet will be overwriten.
I am working on a VBA code to ask a question if the current workbook needs
updating and if yes, then another workbooks worksheet is added.
This will then allow me to copy and paste ranges from one sheet to another
and update records automatically. I figure this is the only way to do it
as
to have both workbooks open and selectively cut and paste from one book to
the other is beyond me.
--
Regards
Bill



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
Import sheet or only data of another workbook [email protected] Excel Programming 0 March 24th 06 09:41 AM
Import/Copy some data from one workbook to a similar workbook [email protected] Excel Programming 11 March 7th 06 12:34 PM
How do I import data from 1 workbook excel sheet into another? LJHolland New Users to Excel 1 June 2nd 05 02:59 PM
Import Sheet from Closed Workbook Joe Derr[_2_] Excel Programming 1 May 2nd 05 09:07 AM
Database Filtering and Import or Copy to Remote Client Workbook battle Excel Programming 0 December 2nd 03 01:02 AM


All times are GMT +1. The time now is 08:42 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"