Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
bay bay is offline
external usenet poster
 
Posts: 3
Default Changing file references in a macro

Hi,

this is a bit tricky, here goes...

I am working on workbook 'Sales 04 12m' and on worsheet 'alpha 12m 04'.
I put a vlookup function that looks up data from a table array in another
workbook for the previous month, which has the same name format "Sales YY
MMm" and from a similar worksheet "alpha 11m 04'.

This macro I use in three different sheets in the workbook I can's go
changing the names each time in the macro. I need a way to specify the
workbook/worksheet from upfront. or even better beacuse it is always one
month back, the macro could figure out the name by itself , could it??

I tried InputBox inside the vllokup function but i get an error, mayby I am
not supposed to use it that way.

Any help appreciated.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Changing file references in a macro

Hi unknown,

try:

Format(Month(Date), "MM")
Format(Year(Date), "YY")

you can use this as reference for your workbook to open
like:

workbooks.open filemane := "c:\some path here\"& Format
(Month(Date), "MM") & ".xls"

Best

Markus


-----Original Message-----
Hi,

this is a bit tricky, here goes...

I am working on workbook 'Sales 04 12m' and on

worsheet 'alpha 12m 04'.
I put a vlookup function that looks up data from a table

array in another
workbook for the previous month, which has the same name

format "Sales YY
MMm" and from a similar worksheet "alpha 11m 04'.

This macro I use in three different sheets in the

workbook I can's go
changing the names each time in the macro. I need a way

to specify the
workbook/worksheet from upfront. or even better beacuse

it is always one
month back, the macro could figure out the name by

itself , could it??

I tried InputBox inside the vllokup function but i get an

error, mayby I am
not supposed to use it that way.

Any help appreciated.

Thank you
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
bay bay is offline
external usenet poster
 
Posts: 3
Default Changing file references in a macro

Marcus,

I am not sure what to do with the code you send me. Let me show you the code
I have.

Range("A1").Select
Columns("D:D").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = _

"=IF(RC[-2]=0,"""",VLOOKUP(R[158]C[-2],'[Sales_04-11m.xls]Sale11m''04
(ii)'!R2C2:R65000C4,3,FALSE))"
ActiveWindow.SmallScroll Down:=-3

I want to be able to change the 04-11 part and the 11m'04 part.

Thank you,

bay

"Markus Scheible" wrote:

Hi unknown,

try:

Format(Month(Date), "MM")
Format(Year(Date), "YY")

you can use this as reference for your workbook to open
like:

workbooks.open filemane := "c:\some path here\"& Format
(Month(Date), "MM") & ".xls"

Best

Markus


-----Original Message-----
Hi,

this is a bit tricky, here goes...

I am working on workbook 'Sales 04 12m' and on

worsheet 'alpha 12m 04'.
I put a vlookup function that looks up data from a table

array in another
workbook for the previous month, which has the same name

format "Sales YY
MMm" and from a similar worksheet "alpha 11m 04'.

This macro I use in three different sheets in the

workbook I can's go
changing the names each time in the macro. I need a way

to specify the
workbook/worksheet from upfront. or even better beacuse

it is always one
month back, the macro could figure out the name by

itself , could it??

I tried InputBox inside the vllokup function but i get an

error, mayby I am
not supposed to use it that way.

Any help appreciated.

Thank you
.


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
changing a macro each time the file name changes andrewc Excel Discussion (Misc queries) 4 January 5th 09 09:04 PM
Unable to run excel macro after changing file name merf New Users to Excel 2 June 14th 05 03:16 PM
How do I create a macro, that references another excel file ??? Aries Excel Worksheet Functions 1 May 25th 05 11:37 AM
Using macro to save xls as txt without changing originial xls file ssciarrino Excel Programming 4 November 2nd 04 02:20 PM
Using Macro to Save xls to txt without changing file format SSciarrino Excel Programming 0 November 1st 04 06:15 PM


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