macro problem

G

Gerbatin

Now I have:

Keyboard Shortcut: Ctrl+Shift+N

Dim myName As String
myName = "LTP0" & Format(Date, "mmdd")
'
Sheets(myName).Select
Sheets(myName).Name = "matriz2"


Range("C5").Select
ChDir "C:\Office 97\Internet"
ActiveWorkbook.SaveAs Filename:="C:\Office 97\Internet\matriz2.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

When I run it I see Run time error 9

Subscript out of range; if I choose debug it stops a
Sheets(myName).Select(yellow bar)
 
D

Dave Peterson

That means you don't have a worksheet by the name of: LTP0MMDD (with mmdd
replaced by the current date's month & day).

If that workbook gets created each day and it only has one worksheet, you can
use:

sheets(1).select
sheets(1).name = "matriz2"
 

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

Similar Threads


Top