use only part of window name in a macro

  • Thread starter Thread starter Paul B
  • Start date Start date
P

Paul B

How would you use only part of the window name in a macro, the dates will
change so I only need to use Time Sheet For



Windows("Time Sheet For 09.18.2008 To 10.01.2008.xls").Activate
 
You could do something like this

Dim myWB As Excel.Workbook
For Each myWB In Application.Workbooks
If myWB.Name Like "Time Sheet For*" Then
Windows(myWB.Name).Activate
Exit For
End If
Next myWB
 
What are you trying to do? Maybe if you state what your goal is, we
can assist you better.

--JP
 
I am just wanting to arrange some windows like below, but the time sheet one
will change names

Windows.Arrange ArrangeStyle:=xlHorizontal
Windows("FF Time").Activate
With ActiveWindow
.Width = 765
.Height = 232.5
End With
ActiveWindow.SmallScroll Down:=2

Windows("Time Sheet For 09.18.2008 To 10.01.2008.xls").Activate
With ActiveWindow
.Width = 765
.Height = 255
End With
With ActiveWindow
.Top = 260.5
.Left = 0.25
End With



What are you trying to do? Maybe if you state what your goal is, we
can assist you better.

--JP
 
Just assign the changing filename part to a string variable. Then you
can change the variable without hard-coding the dates (and potentially
having to change it every two weeks).


Dim strDate As String

strDate = "09.18.2008 To 10.01.2008"

Windows("Time Sheet For " & strDate & ".xls").Activate


--JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top