Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Opening Excel File from value in active cell

I do need some help . . . please. Hope someone can help.

'HERE IS WHAT I NEED AS PART OF MY MACRO . . . . . . . I HAVE AN OPEN
WORKBOOK.
'The name of the active workbook is PacificWindsRentRoll.
xls
'The macro selects . . .
Range("AD100").Select
'In cell AD100, the activecell, is a numeric value . . .
LET'S USE 10 AS OUR EXAMPLE
'I need to open a workbook from folder MyExcel and the
file name is 10.xls
'After the file has been opened, the program needs to re-
activate PacificWindsRentRoll.xls
'Next, the range ("ab100:ao100") needs to be selected and
copied
'The file ( 10.xls ) that we just opened needs to be re-
activated.
'The copied range is then pasted into cell A2 of 10.xls.
'This file 10.xls is then saved and closed.

'The next time this is run, a different file name would be
opened, as the value in cell AD100
'changes.
'My Macro already has a do loop that works and it knows when
to stop.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Opening Excel File from value in active cell

On 7 Mar, 06:42, "Launchnet" <u20911@uwe wrote:
I do need some help . . . please. *Hope someone can help.


HI ! Try this

Range("AD100").Select
If Range("AD100") = 10 Then Workbooks.Open ("D:\MyExcel\10.xls ")
' [the path is for example[
Windows("PacificWindsRentRoll.xls ").Activate
Range("AB100:AO100").Select
Selection.Copy
Windows("10.xls").Activate
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Workbooks("10.xls").Close SaveChanges:=True

{if you want to paste only values you use ,, xlPasteValues"
if not ,you are formula there
only ,,Paste,,without ,,:=xlPasteValues"}


'The next time this is run, a different file name would be
opened, as the value in cell AD100
'changes.
'My Macro already has a do loop that works and it knows when
to stop



I'm shure this is not the full resolve for your problem ,
if next time if value of range AD100 is different the
macro must open another workbook , then there
must use an else , elseif ...something like that ,
maybe somebody else shall help you ;

.
Respectfully
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Opening Excel File from value in active cell

Thanks for your suggestion

Here is what I used and it works great

Sub WorkWithWorkbook()
Dim sFname As String
Dim sPath As String
Dim wsA As Worksheet

sPath = "c:\MyExcel\"

Set wsA = ThisWorkbook.ActiveSheet

sFname = wsA.Range("ad100").Value & ".xls"

Workbooks.Open sPath & sFname

wsA.Range("ab100:ao100").Copy Destination:=Range("a2")
ActiveWorkbook.Close SaveChanges:=True

Set wsA = Nothing
End Sub





Launchnet wrote:
I do need some help . . . please. Hope someone can help.

'HERE IS WHAT I NEED AS PART OF MY MACRO . . . . . . . I HAVE AN OPEN
WORKBOOK.
'The name of the active workbook is PacificWindsRentRoll.
xls
'The macro selects . . .
Range("AD100").Select
'In cell AD100, the activecell, is a numeric value . . .
LET'S USE 10 AS OUR EXAMPLE
'I need to open a workbook from folder MyExcel and the
file name is 10.xls
'After the file has been opened, the program needs to re-
activate PacificWindsRentRoll.xls
'Next, the range ("ab100:ao100") needs to be selected and
copied
'The file ( 10.xls ) that we just opened needs to be re-
activated.
'The copied range is then pasted into cell A2 of 10.xls.
'This file 10.xls is then saved and closed.

'The next time this is run, a different file name would be
opened, as the value in cell AD100
'changes.
'My Macro already has a do loop that works and it knows when
to stop.


--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story. God Bless for everyones help.

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200803/1

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 set up opening a file from a cell in excel spreadsheet Scott Excel Discussion (Misc queries) 1 September 21st 09 06:01 PM
how do i set up opening a file from a cell in excel spreadsheet Scott Excel Discussion (Misc queries) 2 September 21st 09 02:39 PM
On Opening Excel WB the Active cell location never changes den4673 Excel Discussion (Misc queries) 1 March 4th 08 04:51 PM
Why is path name added to active cell when Excel file is saved? [email protected] Excel Discussion (Misc queries) 1 June 28th 07 04:39 PM
Active Cell when opening workbook mwclark0807 Excel Worksheet Functions 3 January 5th 06 04:38 AM


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