Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default calling windows with variables

below is part of a macro which copies information from one
work sheet to another.I switch backwards and forwards
betwen my quote window and my program window several
times.I used to use ActiveWindow.Activate Next but if
there are aother excel windows open it may open the wrong
window.The "myprog" varable work fine and opens the
program window but the "myquote" varaiable doesnt even
though the correct variable is stored(a 4 or 5 digit
number)

myquote = Range("B6")
myprog = Format(Date, "mmmyy")
Workbooks.Open Filename:="\\wxp107475\Brians Docs\Program
Sheets\" & myprog & " Factory Program.xls"
Windows(myquote).Activate'runtime error 9..out of range
'Windows("12000").Activate'the 12000 will change
Sheets("Program").Select
If Range("L13") 0 Then
Range("frames").Sort Key1:=Range("F6"),
Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("frames").Resize(Range("frames").Rows.Count -
Range("M13").Value).Copy
Windows(myprog & " Factory Program").Activate'works fine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default calling windows with variables

What is in cell B6 of the active window?

--

Vasant

"Paul" wrote in message
...
below is part of a macro which copies information from one
work sheet to another.I switch backwards and forwards
betwen my quote window and my program window several
times.I used to use ActiveWindow.Activate Next but if
there are aother excel windows open it may open the wrong
window.The "myprog" varable work fine and opens the
program window but the "myquote" varaiable doesnt even
though the correct variable is stored(a 4 or 5 digit
number)

myquote = Range("B6")
myprog = Format(Date, "mmmyy")
Workbooks.Open Filename:="\\wxp107475\Brians Docs\Program
Sheets\" & myprog & " Factory Program.xls"
Windows(myquote).Activate'runtime error 9..out of range
'Windows("12000").Activate'the 12000 will change
Sheets("Program").Select
If Range("L13") 0 Then
Range("frames").Sort Key1:=Range("F6"),
Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("frames").Resize(Range("frames").Rows.Count -
Range("M13").Value).Copy
Windows(myprog & " Factory Program").Activate'works fine



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default calling windows with variables

Windows(myquote & ".xls").Activate 'runtime

--
Regards,
Tom Ogilvy

"Paul" wrote in message
...
below is part of a macro which copies information from one
work sheet to another.I switch backwards and forwards
betwen my quote window and my program window several
times.I used to use ActiveWindow.Activate Next but if
there are aother excel windows open it may open the wrong
window.The "myprog" varable work fine and opens the
program window but the "myquote" varaiable doesnt even
though the correct variable is stored(a 4 or 5 digit
number)

myquote = Range("B6")
myprog = Format(Date, "mmmyy")
Workbooks.Open Filename:="\\wxp107475\Brians Docs\Program
Sheets\" & myprog & " Factory Program.xls"
Windows(myquote).Activate'runtime error 9..out of range
'Windows("12000").Activate'the 12000 will change
Sheets("Program").Select
If Range("L13") 0 Then
Range("frames").Sort Key1:=Range("F6"),
Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("frames").Resize(Range("frames").Rows.Count -
Range("M13").Value).Copy
Windows(myprog & " Factory Program").Activate'works fine



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default calling windows with variables

Thanks Tom it works!!!!
-----Original Message-----
Windows(myquote & ".xls").Activate 'runtime

--
Regards,
Tom Ogilvy

"Paul" wrote in message
...
below is part of a macro which copies information from

one
work sheet to another.I switch backwards and forwards
betwen my quote window and my program window several
times.I used to use ActiveWindow.Activate Next but if
there are aother excel windows open it may open the

wrong
window.The "myprog" varable work fine and opens the
program window but the "myquote" varaiable doesnt even
though the correct variable is stored(a 4 or 5 digit
number)

myquote = Range("B6")
myprog = Format(Date, "mmmyy")
Workbooks.Open Filename:="\\wxp107475\Brians

Docs\Program
Sheets\" & myprog & " Factory Program.xls"
Windows(myquote).Activate'runtime error 9..out of range
'Windows("12000").Activate'the 12000 will change
Sheets("Program").Select
If Range("L13") 0 Then
Range("frames").Sort Key1:=Range("F6"),
Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("frames").Resize(Range

("frames").Rows.Count -
Range("M13").Value).Copy
Windows(myprog & " Factory Program").Activate'works fine



.

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
cannot open exel from windows xp in windows vista and visa versa lildiana New Users to Excel 4 February 25th 09 07:26 PM
can windows vista edit shared document from windows xp sasa Excel Worksheet Functions 1 January 9th 08 06:44 PM
macro calling another macro + variables yo Excel Discussion (Misc queries) 2 April 5th 06 04:36 PM
Page breaks are different in Windows 2000 and Windows XP Bill Allen Excel Discussion (Misc queries) 1 November 23rd 05 04:42 PM
Calling .Net Windows services Roel Ang Excel Programming 0 May 14th 04 10:55 PM


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