Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Back to original file

I have a macro that opens a file to use for VLOOKUP function. I start in original file, ask user for file to use and I want to execute the function in my original file, not the file I opened

fName = Application.GetOpenFilenam
Workbooks.Open fNam

Range("N2").Selec
ActiveCell.FormulaR1C1 =
"=VLOOKUP(RC[-13],'[fName]Qty-Value'!$A:$C,2,FALSE)

I think I need something before this to capture the name of the original file/worksheet, so I can get back to it before I execute the formula

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Back to original file

Dim sh as Worksheet
set sh = ActiveSheet
fName = Application.GetOpenFilename
Workbooks.Open fName
sh.parent.Activate
sh.Activate

sh.Range("N2") _
.FormulaR1C1 = _
"=VLOOKUP(RC[-13],'[fName]Qty-Value'!$A:$C,2,FALSE)"

--
Regards,
Tom Ogilvy


"brook6" wrote in message
...
I have a macro that opens a file to use for VLOOKUP function. I start in

original file, ask user for file to use and I want to execute the function
in my original file, not the file I opened.

fName = Application.GetOpenFilename
Workbooks.Open fName

Range("N2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-13],'[fName]Qty-Value'!$A:$C,2,FALSE)"

I think I need something before this to capture the name of the original

file/worksheet, so I can get back to it before I execute the formula.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Back to original file

I don't doubt it - that is your formula and it appears screwed up. You have
A1 style references (but pass it to FormulaR1C1), in fact you have a mix of
both reference styles, probably a non-existent name for the workbook in the
formula. But you intimated it worked, so I didn't even look at that.

Sh.Range("N2").FormulaR1C1 =

Part is fine and shouldn't cause an error.

--
Regards,
Tom Ogilvy

"brook6" wrote in message
...
This did get me back to original sheet, but I got 'application-defined or

object-defined' error at the sh.Range line

thx



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Back to original file

This formula worked, prior to inserting in this macro...cleaned up the RC stuf
I am getting 'application-defined or object-defined' error on this line..

ActiveCell.FormulaR1C1 =
"=VLOOKUP(RC[-13],'[fName]Qty-Value'!$c1:$c3,2,FALSE)

I think I may have filename/worksheet syntax issue. Qty-Value is a valid worksheet in the file fName. Not sure on quotes/brackets/space


----- Tom Ogilvy wrote: ----

Dim sh as Workshee
set sh = ActiveShee
fName = Application.GetOpenFilenam
Workbooks.Open fNam
sh.parent.Activat
sh.Activat

sh.Range("N2")
.FormulaR1C1 =
"=VLOOKUP(RC[-13],'[fName]Qty-Value'!$A:$C,2,FALSE)

--
Regards
Tom Ogilv


"brook6" wrote in messag
..
I have a macro that opens a file to use for VLOOKUP function. I start i

original file, ask user for file to use and I want to execute the functio
in my original file, not the file I opened
fName = Application.GetOpenFilenam

Workbooks.Open fNam
Range("N2").Selec

ActiveCell.FormulaR1C1 =
"=VLOOKUP(RC[-13],'[fName]Qty-Value'!$A:$C,2,FALSE)
I think I need something before this to capture the name of the origina

file/worksheet, so I can get back to it before I execute the formula

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
Going back to original location Té Excel Discussion (Misc queries) 1 August 27th 09 03:06 AM
Can I undo a "save file" to revert back to original spreadsheet Nikki Excel Discussion (Misc queries) 5 October 29th 08 03:21 AM
Auto save replaced my original file and now I need the original? Hols Excel Discussion (Misc queries) 1 August 15th 05 10:34 PM
How to revert back to the original file name in a hyperlink VIPIN Excel Discussion (Misc queries) 0 April 17th 05 08:44 AM
using VBA to go back to the original value before the cell was changed mika. Excel Programming 2 September 10th 03 09:09 PM


All times are GMT +1. The time now is 11:13 AM.

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"