Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Copy Range from Open Workbook to Active Workbook

I've created a Macro to copy data from a range in an open workbook
(data source) to an active workbook.
The Macro to do this is located in the source workbook and have
included the syntax below.

Because I've changed the filename the RngToCopy is no longer valid and
I'm hoping that someone can assist in helping me out with what the
syntax should be to prevent it from happening again when the Source
filename is changed.

The End User would open up the relevant workbook for the grant and
call the function. Thus, the grants workbook is the "active workbook"
but as you can see below, I've reference an actual workbook which I
believe isn't the best thing to do.


Ok, I've managed to figure Part A of the problem out, by using the
ThisWorkbook.name

---

Dim RngToCopy As Range
Dim DestCell As Range

Set RngToCopy = Workbooks("GRANT BALANCES - 2008.2009.xls").Worksheets
("Cover") _
.Range("report.cover.range")

Set DestCell = ActiveSheet.Range("B24")

---

It's now......

----

Dim RngToCopy As Range
Dim DestCell As Range
Dim ThisWorkBookName As String

MyWk = ThisWorkbook.Name

Set RngToCopy = Workbooks(MyWk).Worksheets("Cover") _
.Range("report.cover.range")

---

But now I've got this problem.....

---

ActiveCell.Formula = "=VLOOKUP(BProject,'[GRANT BALANCES -
2008.2009.xls]Grants Balance'!$A:$BG,58,FALSE)"
ActiveSheet.Range("B27:F27").Select

----

I would like to know how to get this to work......

Never mind... solved it......

ActiveCell.Formula = "=VLOOKUP(BProject,'[" & MyWk & "]Grants Balance'!
$A:$BG,58,FALSE)"

Even tho I've solved it, I've posted it anyway in the event in may be
of assistance to someene else.
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
Defining a range in a different open workbook from the active one JWirt Excel Programming 1 May 21st 07 06:21 AM
Get range value active workbook on open add-in Ajtb Excel Programming 1 February 11th 05 01:52 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Copy worksheet from Active workbook into all other open workbooks TroyB[_2_] Excel Programming 0 February 10th 04 10:29 AM
How do I make an open workbook the active workbook Don Guillett[_4_] Excel Programming 0 December 30th 03 04:28 PM


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