2013-06-04 57 views
0

我正在運行以下宏,但希望它具有更多功能。此電子表格用於維護客戶並跟蹤多個州內的銷售值。我爲每個工作狀態選擇工作簿。我希望宏提示我輸入當前宏中的數據。我可以添加一些東西給這個宏,這樣它會首先提示我選擇一個基於表名的工作表?我需要我的宏來提示我根據表名選擇工作表

Sub TestMacro() 
Dim dblRow As Double, dtDate As Date, strCustomer As String 
Dim strAddress As String, strZip As String, strEst As String 
    dblRow = InputBox("What Row to Enter On") 
    dtDate = InputBox("Date", , Date) 
    strCustomer = InputBox("Customer") 
    strAddress = InputBox("Address") 
    strZip = InputBox("Zip Code") 
    strEst = InputBox("Estimated Value") 
    Range("A" & dblRow).Value = dtDate 
    Range("B" & dblRow).Value = strCustomer 
    Range("C" & dblRow).Value = strAddress 
    Range("D" & dblRow).Value = strZip 
    Range("E" & dblRow).Value = strEst 
End Sub 
+0

我也忘了補充一點,我想dblRow = InputBox(「什麼行進入ON」),而不是自動選擇下一個可用的行不包含數據。 – user2453620

回答

0

我想通了。這是我的代碼的工作結果。

Sub EnterContact() 
Dim lastrow As Long, strCust As String, strAddress As String 
Dim strTown As String, strZip As String, strPhone As String 
Dim strFax As String, strEmail As String, strContact As String 
Dim strPrior As String, strOrg As String, strProj As String 

With Sheets("Oregon") 
    lastrow = .Range("A" & .Rows.Count).End(xlUp).Row + 1 

    strCust = InputBox("Enter Customer") 
    strAddress = InputBox("Enter Address") 
    strTown = InputBox("Enter Town") 
    strZip = InputBox("Enter Zip Code") 
    strPhone = InputBox("Enter Phone Number") 
    strFax = InputBox("Enter Fax Number") 
    strEmail = InputBox("Enter Email Address") 
    strContact = InputBox("Enter Contact Name") 
    strPrior = InputBox("Enter Priority Level") 
    strOrg = InputBox("Enter Organization") 
    strProj = InputBox("Enter Projected Dollar Amount") 
    Range("A" & lastrow).Value = strCust 
    Range("B" & lastrow).Value = strAddress 
    Range("C" & lastrow).Value = strTown 
    Range("D" & lastrow).Value = strZip 
    Range("E" & lastrow).Value = strPhone 
    Range("F" & lastrow).Value = strFax 
    Range("G" & lastrow).Value = strEmail 
    Range("H" & lastrow).Value = strContact 
    Range("I" & lastrow).Value = strPrior 
    Range("J" & lastrow).Value = strOrg 
    Range("K" & lastrow).Value = strProj 

Dim LRow As Long 
'Find last row in Column A with content 
    LRow = Cells(Rows.Count, 1).End(xlUp).Offset(0, 0).Row 
    Rows("5:" & LRow).Sort Key1:=.Range("C3"), _ 
     Order1:=xlAscending, Header:=xlNo, _ 
     OrderCustom:=1, MatchCase:=False, _ 
     Orientation:=xlTopToBottom 

    End With 
End Sub 
相關問題