2014-09-25 2 views
0

내 매크로는 2010 년 Excel에서 완벽하게 작동했지만 2013 년에 vba에서 통합 문서를 활성화하는 데 큰 문제가 있으며 특정 시트를 선택하고 셀을 선택하면 데이터를 채울 수 있지만 입력 또는 화살표 키를 누르면 데이터가 내 파일의 첫 번째 보이는 페이지로 설정됩니다. 다른 통합 문서를 활성화 할 때이 문제가 발생하지만 특정 시트를 선택하면 같은 통합 문서에서도 입력 한 데이터가 첫 번째 시트로 이동합니다 ... 2010 년 Excel 2010에서 2013로 변경되면서 이런 일이 발생합니까 ?? 대부분 ...엑셀 2013에서 워크 시트를 활성화 할 때의 문제

Workbooks(MachineInspectieLijst & ".xlsm").Activate 
Workbooks(MachineInspectieLijst & ".xlsm").Worksheets(MachineInspectieLijst).Range("V5").Select 

내가 V5에 값을 기입하고 입력 값이 사라지고 첫 페이지에 V5에 나타납니다 :

은 내가 사용하는 코드입니다.

페이지 또는 통합 문서를 수동으로 전환 할 때 작동하는 것보다 ... 답변을 찾을 수 없습니다.

누군가가 답을 갖고 있기를 바랍니다. 통합 문서를 활성화 할 때

Sub hfjsdfh() 
    Workbooks(MachineInspectieLijst & ".xlsm").Activate 
    Worksheets(MachineInspectieLijst).Select 
    Range("V5").Select 
End Sub 
+0

, 당신이 당신이 거기에 있었다 그것은 지난 번에 있었던 마지막 시트에 간다 : –

답변

0

프로세스 순차적으로 작업을 수행합니다. 따라서 원하는 시트를 활성화 시트로 만들어야합니다. 그렇지 않으면 잘못된 페이지에 내용을 쓰게됩니다. 여전히 V5가 원하는 페이지에서 선택되지만 코드로 해당 페이지에 있지는 않습니다. 그럼에도 불구하고, 나는 결코 활성화 또는 선택을 사용하지 않는 것이 좋습니다. 코드 시작 부분에 application.enableevents = false를 추가하고 마지막에 true로 재설정하여 이벤트를 사용하지 않도록 설정할 수도 있습니다.
0
This is the actual sub, I tried your suggestion, but exactly the same...Indeed, it is like the second workbook is not really activated, but how to solve? has it to do with the userform who stays loaded? this one must stay loaded, as it contains lot of necessary information and is only unloaded at new start. Nevertheless, I tried to unload as test, but same problem. Can it be due to excel itself? 

Private Sub CmdGetInspectionList_Click() 
Dim thesentence As String 
Dim WB As Workbook 
Set WB = ThisWorkbook 
Dim WB2 As Workbook 
frmKlantSelectie.Hide 
Application.EnableEvents = False 
If Me.cboDocumentType.Value = "Sales Budget Quotation" Then 
    MachineInspectieLijst = "Machines_Sales" 
    WB.Worksheets("PreInspArticles").Range("J1") = "Sales" 
Else 
    MachineInspectieLijst = Me.cboInspectieMachine.Value 
End If 
loginnaam = StrConv(WindowsUserName, vbUpperCase) 
thesentence = "C:\Users\" & loginnaam & "\Dropbox\2_Doc_Service\DATA\Pre_Inspection_Checklist\" &  MachineInspectieLijst & ".xlsm" 

'checken ofdat de file wel bestaat in de directory 
If Dir(thesentence) <> "" Then 
    MsgBox "Machine Check list exists! Press 'OK' and file will be shown!" 
'Test to see if the file is open. 
    If IsFileOpen(thesentence) Then 
     Workbooks(MachineInspectieLijst & ".xlsm").Activate 
    Else 
'Display a message stating the file is not in use. 
    Set WB2 = Workbooks.Open(thesentence) 
End If 
    Else 
    MsgBox "No machine selected Or Check list not yet existing." 
    frmKlantSelectie.Show 
    Me.TxtInspectionList.SetFocus 
    Exit Sub 
    End If 
    WB2.Worksheets(1).Range("V5").Select 
    Application.EnableEvents = True 

    End Sub 
관련 문제