Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Select failed?

Posted this earlier, but didn't get any satisfactory answer to my
problem.
Here's the code I've written so far:

Sub CopyModFile2PIP()
Dim sDirBase As String
Dim sFName As String
Dim lAns As Long
Dim sFileType As String
Dim sShtName As String
Dim oPIP As Object
Set oPIP = Workbooks("PIP DD Template.xls")


'Application.ScreenUpdating = False
lAns = MsgBox("Is the current Mod directory selected?", vbYesNo)
Select Case lAns
Case vbYes
sDirBase = "H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Mod\"
sFName = Dir(sDirBase)
Do Until sFName = ""


sShtName = Left(sFName, Len(sFName) - 7)
sShtName = sShtName & "Records"
oPIP.Worksheets(sShtName).Select<------ERROR
Loop
Case vbNo
Application.ScreenUpdating = True
Exit Sub


End Select


Application.ScreenUpdating = True
End Sub

Am getting a "Select method fail" error at the marked spot. Any ideas?
Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Select failed?

If that sShtName actually exists in the oPIP workbook (I'd double check that
first), then you can't select a worksheet in a workbook that's not active:

opip.activate
oPIP.Worksheets(sShtName).Select

Maybe????



davegb wrote:

Posted this earlier, but didn't get any satisfactory answer to my
problem.
Here's the code I've written so far:

Sub CopyModFile2PIP()
Dim sDirBase As String
Dim sFName As String
Dim lAns As Long
Dim sFileType As String
Dim sShtName As String
Dim oPIP As Object
Set oPIP = Workbooks("PIP DD Template.xls")

'Application.ScreenUpdating = False
lAns = MsgBox("Is the current Mod directory selected?", vbYesNo)
Select Case lAns
Case vbYes
sDirBase = "H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Mod\"
sFName = Dir(sDirBase)
Do Until sFName = ""

sShtName = Left(sFName, Len(sFName) - 7)
sShtName = sShtName & "Records"
oPIP.Worksheets(sShtName).Select<------ERROR
Loop
Case vbNo
Application.ScreenUpdating = True
Exit Sub

End Select

Application.ScreenUpdating = True
End Sub

Am getting a "Select method fail" error at the marked spot. Any ideas?
Thanks.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Select failed?


Dave Peterson wrote:
If that sShtName actually exists in the oPIP workbook (I'd double check that
first), then you can't select a worksheet in a workbook that's not active:

opip.activate
oPIP.Worksheets(sShtName).Select

Maybe????


Activating it did the trick! Thanks, Dave!



davegb wrote:

Posted this earlier, but didn't get any satisfactory answer to my
problem.
Here's the code I've written so far:

Sub CopyModFile2PIP()
Dim sDirBase As String
Dim sFName As String
Dim lAns As Long
Dim sFileType As String
Dim sShtName As String
Dim oPIP As Object
Set oPIP = Workbooks("PIP DD Template.xls")

'Application.ScreenUpdating = False
lAns = MsgBox("Is the current Mod directory selected?", vbYesNo)
Select Case lAns
Case vbYes
sDirBase = "H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Mod\"
sFName = Dir(sDirBase)
Do Until sFName = ""

sShtName = Left(sFName, Len(sFName) - 7)
sShtName = sShtName & "Records"
oPIP.Worksheets(sShtName).Select<------ERROR
Loop
Case vbNo
Application.ScreenUpdating = True
Exit Sub

End Select

Application.ScreenUpdating = True
End Sub

Am getting a "Select method fail" error at the marked spot. Any ideas?
Thanks.


--

Dave Peterson


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
Select failed? davegb Excel Programming 5 July 12th 05 04:39 PM
What did I do? (Select Method of Range Class Failed ) HotRod Excel Programming 9 May 20th 05 02:11 PM
Select method of Range class failed - but why??? Orion[_2_] Excel Programming 3 December 21st 04 03:28 PM
select method of range class failed Joseph[_40_] Excel Programming 0 September 28th 04 04:08 PM
select method of range class failed Joseph[_39_] Excel Programming 0 September 28th 04 02:32 PM


All times are GMT +1. The time now is 02:36 AM.

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"