まず、この質問が既に別の場所で回答されている場合は、お詫び申し上げます。私は見栄えはしましたが、私を助けるものは何も見つかりませんでした。セルの値を別のワークブックにコピー
第二に、私はこれを行うもっと簡単な方法があると確信していますが、私は非常に新しいVBAであり、私は一緒に行くように自分自身を教えようとしています。
これで、前のシートの情報をコンパイルするシートがブックの最後にあり、2行目のすべての値がネットワークドライブを持つ別のブックにコピーされます。
私は、同じシート上で動作するようになっていますが、別のブックには(ユーザーフォームを使用せずに)動作させることができました。
それは 細胞(emptyRow、1.Valueラインは '無効な修飾子' エラーで戻ってくる - 誰場合はここでDateRaised.Value
以下の私のコードで、
Sub CommandButton1_Click()
Dim emptyRow As Long
Dim DateRaised As Long
Dim CustomerName As String
Dim SiteAddress As String
Dim CallReason As String
Dim CustomerOrderNo As Long
Dim InvoiceNo As Long
Dim CovernoteNo As Long
Dim Findings As String
Dim ProductType As String
Dim Supplier As String
Dim Attempts As Long
Dim Condition As String
Dim DateClosed As Long
Dim CreditGiven As String
Dim CreditValue As Long
Dim IssueDays As Long
Dim Comments As String
DateRaised = Cells(2, "A").Value
CustomerName = Cells(2, "B").Value
SiteAddress = Cells(2, "C").Value
CallReason = Cells(2, "D").Value
CustomerOrderNo = Cells(2, "F").Value
InvoiceNo = Cells(2, "G").Value
CovernoteNo = Cells(2, "H").Value
Findings = Cells(2, "I").Value
ProductType = Cells(2, "J").Value
Supplier = Cells(2, "K").Value
Attempts = Cells(2, "L").Value
Condition = Cells(2, "M").Value
DateClosed = Cells(2, "N").Value
CreditGiven = Cells(2, "O").Value
CreditValue = Cells(2, "P").Value
IssueDays = Cells(2, "Q").Value
Comments = Cells(2, "R").Value
Dim WrkBk As Workbook
Dim WrkSht As Worksheet
Set WrkBk = Workbooks.Open("R:\6024 Onsite\COVER NOTE WORKFLOW\Database\Covernote Databse.xlsx")
Set WrkSht = WrkBk.Sheets("Covernote Database")
WrkSht.Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Cells(emptyRow, 1).Value = DateRaised.Value
Cells(emptyRow, 2).Value = CustomerName.Value
Cells(emptyRow, 3).Value = SiteAddress.Value
Cells(emptyRow, 4).Value = CallReason.Value
Cells(emptyRow, 5).Value = CustomerOrderNo.Value
Cells(emptyRow, 6).Value = InvoiceNo.Value
Cells(emptyRow, 7).Value = CovernoteNo.Value
Cells(emptyRow, 8).Value = Findings.Value
Cells(emptyRow, 9).Value = ProductType.Value
Cells(emptyRow, 10).Value = Supplier.Value
Cells(emptyRow, 11).Value = Attemps.Value
Cells(emptyRow, 12).Value = Condition.Value
Cells(emptyRow, 13).Value = DateClosed.Value
Cells(emptyRow, 14).Value = CreditGiven.Value
Cells(emptyRow, 15).Value = CreditValue.Value
Cells(emptyRow, 16).Value = IssueDays.Value
Cells(emptyRow, 17).Value = Comments.Value
WrkBk.Close (SaveChanges = False)
End Sub
'DateRaised'はセルではありません...このように' Cells(emptyRow、1).Value = DateRaised'は '.Value'なし...他の行と同じです –
また、' Dim AllValues As 「AllValues = [A2:R2] .Value2」のバリエーションが可能です。 –
@DirkReichel:値に「穴」があります:フォームの列「A」から「D」までの範囲になります。また、「Cells(emptyRow、1).Resize(、17).Value = AllValues'; "F"から "R"へ – user3598756