2017-12-20 32 views
1

다음은 현재 일부 인보이스 탭에 사용중인 매크로입니다. 통합 문서의 첫 번째 시트는 하이퍼 링크의 워크 시트 이름을 사용하여 인덱싱하도록 설정됩니다. 이 모듈은 crtl + shift + n에 의해 활성화되도록 설정되었습니다. 두 번째 하위 두 번째 번 내가 그것을 시도했지만 지금은 이전 행에서 채워진 첫 번째 빈 행 가득 채우는 데이터를 복사하지 않았다. 첫 번째 하위 이후에 멈추는 것처럼 보입니다. 어떤 아이디어?매크로 for excel VBA는 동일한 모듈에서 두 번째 하위를 실행하지 않습니다.

Option Explicit 

Sub NewRequistionRecord() 
' 
' NewRequistionRecord Macro 
' Used for creaing a new requistion record to be auto updated in master 
Requisitions worksheet 
' 
' Keyboard Shortcut: Ctrl+Shift+N 
' 

Dim wb As Workbook: Set wb = ThisWorkbook 
Dim ws As Worksheet: Set ws = wb.sheets("BlankReq") 
Dim wbBefore As Workbook: Set wbBefore = Application.Workbooks("OPP Stores 
Orders Macro.xlsm") 
Dim wsBefore As Worksheet: Set wsBefore = wbBefore.sheets("BlankReq") 
Dim answer 
Dim NewName As String 
Application.ScreenUpdating = False 

    ws.Select 'Goes to template worksheet 


    ws.Copy Before:=wsBefore ' Forces a copy to be made always before the template so it is always at the end  
sheets("BlankReq (2)").Select 
sheets("BlankReq (2)").Name = "Enter Req Number" ' changes the name to indicate a requisition number needs to be entered 
Range("A1").Select ' hyperlink goes back Master Req index page 
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True 

Application.ScreenUpdating = True 

sheets("Enter Req Number").Select 
answer = MsgBox("Please rename the sheet with the Requisition number", vbOK) 

    If answer = vbOK Then 

Another: 
    NewName = InputBox("Requisition number - ?") 
    ActiveSheet.Name = NewName 

    Range("D2").Select 
    NewName = InputBox("Requisition Description- NO SPACES!! USE UNDERSCORE ?") 
    Range("D2").Value = NewName 
    wsBefore.Select 

    Range("H2").Select 
    NewName = InputBox("Please enter Requested By ") 
    Range("H2").Value = NewName 
    wsBefore.Select 
    answer = MsgBox("Please select your data to copy and paste into this sheet. Line Cost must be selected seperately from the items.", vbOKOnly) 

    End If 

End Sub 


Sub Filldown() 
Dim strFormulas(1 To 6) As Variant 
Dim wb As Workbook: Set wb = ThisWorkbook 
Dim ws As Worksheet: Set ws = wb.ActiveSheet 
Dim wbBefore As Workbook: Set wbBefore = Application.Workbooks("OPP StoresOrders Macro.xlsm") 
Dim wsBefore As Worksheet: Set wsBefore = wbBefore.sheets("BlankReq") 
Dim LRow As Long 
Dim xRow As Variant 
Application.ScreenUpdating = False 

     With ThisWorkbook.sheets("Requisitions") 
     Range("A1").Select 
     Columns("B:K").Select 
     Selection.SpecialCells(xlCellTypeBlanks).Select 
     Selection.FormulaR1C1 = "=R[-1]C" 
     End With 




Application.ScreenUpdating = True 

End Sub 

답변

1

바로 가기는 모듈이 아니라 Sub로 설정됩니다. 따라서 두 번째 하위는 아마도 기본적으로 실행되지 않습니다.

먼저 제 1 서브를 실행하려면 다음 두 번째 서브는 다음과 같은 시도 :

Sub TestMe() 
    NewRequistionRecord 
    FillDown 
End Sub 
+1

감사합니다. 감사합니다. – mrautomation

0

을 당신은 전혀 번째 매크로를 호출 아닙니다. 따라서 코드를 실행하고 두 번째 매크로를 실행하라는 메시지를 얻지 못합니다. 두 번째 매크로를 실행하기 위해 프로그램을 어떻게 든 말할 필요가 있습니다 - 내가 좋아하는 것입니다. call Macroname

+0

제안 해 주셔서 감사합니다. 나는 아직도 이것에 아주 새롭다. – mrautomation

+0

이봐, 우리 모두 어딘가 시작! 스프레드 시트와 같은 모듈을 생각해보십시오. 코드를 저장하면됩니다. 모듈 내의 각 하위는 별도의 매크로입니다. 각 개별 매크로에 바로 가기/단추를 만들 수 있습니다. 한 번에 여러 매크로를 사용하려면 Sub Wrapper()처럼 모두 래퍼 매크로를 사용해야합니다. Macro1 호출 Macro2 호출 End 서브 – Selkie

+0

'Call' 문은 더 이상 사용되지 않으므로 사용하면 안됩니다 더 이상. 대신'Macroname'을 쓰십시오 (호출하지 않음). –