Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default UserForm referring to another excel file

I currently use PERSONAL.xls to hold all of my macros and my one user
form. Every day I open a file exported from excel (titled
ListingsMM-DD-YYYY.xls). I use a macro from PERSONAL to format
everything on the Listings file. I'm now trying to implement new things
that use another macro to in PERSONAL to start the userform, gather
what variables the user wants to graph (a list of what they can pick is
in a sheet called wksInfo- names of their ranges have already been
created- "Letter" and "Yaxis"), and then to graph certain things from
another worksheet in the Listings file based off of the user's input.
I would only start the user form when I already have the Listings file
opened.

I think I just need somehow to make this user form inside of my
PERSONAL.xls refer to the Listings file correctly. I've incorrectly put
"Files("Listings11-5-2005.xls")." in to try to fix it and even
hard-coded the date in to see if it worked- nothing. I have been unable
to find much relevant info about my problem, but I'm sure that visual
basic can manipulate multiple files somehow. Is there some way I could
make it refer to the Listings file I have open or the most recent
Listings file in a certain folder?


Here's where my form's code is messing up:

Private Sub UserForm_Initialize()
Dim cLoc As Range
Dim cYok As Range


For Each cLoc In
Files("Listings11-5-2005.xls").Sheets("wksInfo").Range("Letter")
With Me.letter
.AddItem cLoc.Value
.List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
End With
Next cLoc

For Each cYok In
Files("Listings11-5-2005.xls").Sheets("wksInfo").Range("Yaxis")
With Me.yAxis
.AddItem cYok.Value
.List(.ListCount - 1, 1) = cYok.Offset(0, 1).Value
End With
Next cYok

Me.letter.SetFocus

End Sub



I'm running Excel 2002- I'm still pretty new at all of this visual
basic/excel/macro stuff, so thanks for your help.

Regards,
Brett

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default UserForm referring to another excel file

Use.....Workbooks not Files to refer to an open workbook (file name) ....

Workbooks("Listings11-5-2005.xls").Sheets("wksInfo").Range("Letter")


--
Cheers
Nigel



"B Smith" wrote in message
oups.com...
I currently use PERSONAL.xls to hold all of my macros and my one user
form. Every day I open a file exported from excel (titled
ListingsMM-DD-YYYY.xls). I use a macro from PERSONAL to format
everything on the Listings file. I'm now trying to implement new things
that use another macro to in PERSONAL to start the userform, gather
what variables the user wants to graph (a list of what they can pick is
in a sheet called wksInfo- names of their ranges have already been
created- "Letter" and "Yaxis"), and then to graph certain things from
another worksheet in the Listings file based off of the user's input.
I would only start the user form when I already have the Listings file
opened.

I think I just need somehow to make this user form inside of my
PERSONAL.xls refer to the Listings file correctly. I've incorrectly put
"Files("Listings11-5-2005.xls")." in to try to fix it and even
hard-coded the date in to see if it worked- nothing. I have been unable
to find much relevant info about my problem, but I'm sure that visual
basic can manipulate multiple files somehow. Is there some way I could
make it refer to the Listings file I have open or the most recent
Listings file in a certain folder?


Here's where my form's code is messing up:

Private Sub UserForm_Initialize()
Dim cLoc As Range
Dim cYok As Range


For Each cLoc In
Files("Listings11-5-2005.xls").Sheets("wksInfo").Range("Letter")
With Me.letter
.AddItem cLoc.Value
.List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
End With
Next cLoc

For Each cYok In
Files("Listings11-5-2005.xls").Sheets("wksInfo").Range("Yaxis")
With Me.yAxis
.AddItem cYok.Value
.List(.ListCount - 1, 1) = cYok.Offset(0, 1).Value
End With
Next cYok

Me.letter.SetFocus

End Sub



I'm running Excel 2002- I'm still pretty new at all of this visual
basic/excel/macro stuff, so thanks for your help.

Regards,
Brett



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
referring to sheet in another file Tami Excel Worksheet Functions 1 May 31st 08 04:33 PM
referring to a sheet in another file Tami Excel Worksheet Functions 1 May 31st 08 01:56 PM
Referring to a variable file name Brettjg Excel Discussion (Misc queries) 4 March 3rd 07 11:18 AM
referring to a cell containing a file name [email protected] Excel Discussion (Misc queries) 2 December 4th 06 05:03 PM
Referring to file no's from within an add-in gives problems PaLPiTaTioN Excel Programming 0 March 18th 05 06:35 AM


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