0
COUNTIF式に基づいていくつかの行を追加する必要があるマクロを作成中です。VBAを使用してセル内の特定の数値に基づいて行を追加します。
=COUNTIF(D2:D1000,">=1/1/2017")-COUNTIF(D2:D1000,">1/2/2018")
ので、基本的に、私は、日が私のソーススプレッドシートに範囲内に現れるすべての回を数え、カウントを返し、新しいを追加するための式を使用し、私の先のシートにその式を置くことができるようにしたいです値が何であるかに基づいて行を作成します。数式は正確で、現時点で間違った場所にあるだけです(ソースのスプレッドシートであり、宛先ではありません)。私はいくつかのコードの開始点を持っていますが、私は自分の目標を達成するために次に行くべきところに苦労しています。誰でも助けてくれますか?
Sub Map_To_Import_Sheet()
Dim wbs As Workbook 'Source workbook
Dim wbd As Workbook 'Destination workbook already open
Dim ss As Worksheet 'Source worksheet
Dim ds As Worksheet 'Destination worksheet
Set wbd = ThisWorkbook
Set wbs = Workbooks.Open("S:\Accounts (New)\Management Information
(Analysis)\Phil Hanmore - Analysis\Neil Test\TimeSheet Templates\Copy of
MSI shifts 19th June - 25th June.xlsx")
Set ss = wbs.Worksheets(1)
Set ds = wbd.Worksheets("Import Sheet")
'Removes the data from the columns A through R in NHSP Import Template
ds.Range(ds.Range("A4:R18"),
ds.Range("A4:R18").End(xlDown)).ClearContents
'Counts the rows with data on the source spreadsheet and adds the
appropriate number to the destination (Import sheet)
ss.Activate
操作の例を教えてください。 (たとえば、数式はセルA3にあり、destShtのセルA5に入る必要があります。次に、数式の値に基づいて行6の後にx行をdestShtに挿入します) – takanuva15