Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Auto Import From Other Doc

What code would i have to put in so that everytime you clicked a button a
macro would automatically pull data from another excel sheet and drop it into
my workbook so i can do calculations with it???

Cheers
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 267
Default Auto Import From Other Doc

how about copying selected range and pasting it into the new doc via a
command button.

Go view-toolbars-control toolbox: click design mode then command button,
click where you want the buttton placed on your worksheet, while still in
design mode double click the command button this will open the vb editor
paste the following in the


Private Sub CommandButton1_Click()

Workbooks("book1").Worksheets("Sheet1").Range("C1: C5").Copy
ActiveSheet.Paste
Destination:=Workbooks("book2").Worksheets("Sheet1 ").Range("c1:c5")
CutCopyMode = False

End Sub

obviously replace your names for workbooks and worksheets and ranges in the
above code.
Close the ditor and click to exit design mode.
Your command button should now copy and paste from one workbook to another.

"Gazz_85" wrote:

What code would i have to put in so that everytime you clicked a button a
macro would automatically pull data from another excel sheet and drop it into
my workbook so i can do calculations with it???

Cheers

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Auto Import From Other Doc

Hi,

it threw an error for the colon after destination so i deleted it except it
doesnt paste it in the correct place it just sticks it in the cell which is
currently selected.

any suggestions???

Cheers

Destination:=

"Atishoo" wrote:

how about copying selected range and pasting it into the new doc via a
command button.

Go view-toolbars-control toolbox: click design mode then command button,
click where you want the buttton placed on your worksheet, while still in
design mode double click the command button this will open the vb editor
paste the following in the


Private Sub CommandButton1_Click()

Workbooks("book1").Worksheets("Sheet1").Range("C1: C5").Copy
ActiveSheet.Paste
Destination:=Workbooks("book2").Worksheets("Sheet1 ").Range("c1:c5")
CutCopyMode = False

End Sub

obviously replace your names for workbooks and worksheets and ranges in the
above code.
Close the ditor and click to exit design mode.
Your command button should now copy and paste from one workbook to another.

"Gazz_85" wrote:

What code would i have to put in so that everytime you clicked a button a
macro would automatically pull data from another excel sheet and drop it into
my workbook so i can do calculations with it???

Cheers

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Auto Import From Other Doc

Both workbooks need to be open.

workbooks("someotherworkbook.xls").worksheets("She et2").range("a1:B99").copy _
destination:=activesheet.range("A1")



Gazz_85 wrote:

What code would i have to put in so that everytime you clicked a button a
macro would automatically pull data from another excel sheet and drop it into
my workbook so i can do calculations with it???

Cheers


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Auto Import From Other Doc

is there anyway to do this without both workbooks being open??

"Dave Peterson" wrote:

Both workbooks need to be open.

workbooks("someotherworkbook.xls").worksheets("She et2").range("a1:B99").copy _
destination:=activesheet.range("A1")



Gazz_85 wrote:

What code would i have to put in so that everytime you clicked a button a
macro would automatically pull data from another excel sheet and drop it into
my workbook so i can do calculations with it???

Cheers


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Auto Import From Other Doc

I think you can do some ADO stuff, but it's beyond me.

But your code could open the workbook, copy and paste the range and close the
workbook. You'd never know that it happened.

Dim wkbk as workbook
dim actwks as worksheet

set actwks = activesheet

application.screenupdating = false
set wkbk = workbooks.open(filename:="c:\somefile.xls", readonly:=true)
wkbk.worksheets("Sheet2").range("a1:B99").copy _
destination:=actwks.range("A1")
wkbk.close savechanges:=false
application.screenupdating = true







Gazz_85 wrote:

is there anyway to do this without both workbooks being open??

"Dave Peterson" wrote:

Both workbooks need to be open.

workbooks("someotherworkbook.xls").worksheets("She et2").range("a1:B99").copy _
destination:=activesheet.range("A1")



Gazz_85 wrote:

What code would i have to put in so that everytime you clicked a button a
macro would automatically pull data from another excel sheet and drop it into
my workbook so i can do calculations with it???

Cheers


--

Dave Peterson


--

Dave Peterson
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
How do I import from csv file without auto formatting? zvikam Excel Discussion (Misc queries) 5 July 15th 08 01:00 PM
Auto-import csv into Excel? CW Excel Discussion (Misc queries) 0 September 12th 06 02:54 PM
Auto-Import and sort data in Excel NJ Desi Bhai Excel Worksheet Functions 1 March 8th 06 04:33 PM
Auto Import OR Searching TXT Data [email protected] Excel Worksheet Functions 1 February 23rd 06 06:32 PM
how do I import a csv files to execl and be extrad on clume auto saber55 New Users to Excel 0 February 16th 06 01:30 PM


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

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

About Us

"It's about Microsoft Excel"