Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Select failed? | Excel Programming | |||
What did I do? (Select Method of Range Class Failed ) | Excel Programming | |||
Select method of Range class failed - but why??? | Excel Programming | |||
select method of range class failed | Excel Programming | |||
select method of range class failed | Excel Programming |