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
4

1 に答える 1

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
于 2013-06-10T18:56:28.533 に答える