View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Paul Paul is offline
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