2017-12-24 11 views
0

Excelで特定のシートに書き込もうとしている倍数の配列があります。シート内の使用済みデータの最後の列に範囲を挿入する

このシートには既にデータがあります。そこに使用されたデータの最後の列を見つける方法を示し、列のNUMBERを返す多くのコードスニペットがあります。しかし、文字列を文字列として必要とするrange関数を使用して、配列にデータを書き込もうとしています。これを行うより良い方法はありますか?

はここに、これまでに私のコードです:

Dim lCol As Integer 
     With GlobVars.Wksht 
      lCol = .Cells(1, .Columns.Count).End(Excel.XlDirection.xlToLeft).Column 
     End With 
     lCol += 1 
     GlobVars.Wksht.Range("I need something in these parentheses that will relate the lcol value and whatever row I want to put it in").Value = deltaxyarr 'copies the deltaxyarr as a range into the current active worksheet (data reduction) 
+0

これは実際にVB.NETですか? A .NETの「Long」が間違っているようです – Plutonix

+0

10進数型のデータ型であるため、データ型としてlongを選択しました。コピーする配列のデータ型をExcelに変更しますが、データの次の未使用列の範囲に書き込む方法の構文に真に関心があります。 編集:これを変更できますDecimalとして、しかしそれは本当に私がそれについて望んでいる何かを変えないだろうか? :) –

+0

ロングは整数型です - 小数点はありません。 > 9,000,000,000,000,000,000は列数よりもはるかに多いようです – Plutonix

答えて

0

ワークシートに、配列を転送するためには、配列のサイズと同じ範囲の大きさを持っている必要があります。これを行うには、便利なResizeプロパティを使用できます。ここでは、物事がどのように動作するかです:私はCells.Addressメンバーを使用して作業いくつかのコードを取得することができたQharrする

Sub TransferArray() 

    Dim arr As Variant 

    'Copy range into array. 
    'This array is 1) always 2-dimensional and 2) its lower bound is always 1. 
    arr = Range("A1:F10") 

    'To transer array, the receiving range should accomodate array fully. 
    'To do it, we can use Resize property. 
    'This means, all we need is to choose top left cell of our receiving range. 
    'Here K1 cell is this very cell. 
    'The RowSize argument means how many rows we should expand down, 
    'and ColumnSize - how many column we should expand right. 
    'Apparently, these numbers are upper bound of 1-st dimension 
    'and upper bound of 2-nd dimension, respectively. 
    Range("K1").Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr 

End Sub 
+0

こんにちは。私はシート上に配列を配置する場所の正確な位置を特定しようとしています。たとえば、エクセルのA1:C5からのデータ(常に5x3の配列)が表示されます。 D1から始まる最初のデータセットの次に配置したい別の配列がありますが、次の未使用の列を見つけるコード行が必要です。次に、このコード行が機能するように未使用の列を配置するコード行が必要です。 {範囲(「開始セルD1ここ」)。サイズ変更(UBound(arr、1)、UBound arr、2))。値= arr} –

0

感謝の。

  lCol = .Cells(1, .Columns.Count).End(Excel.XlDirection.xlToLeft).Column 

      lCol += 1 
      GlobVars.Wksht.Range(GlobVars.Wksht.Cells(1, lCol).Address).Resize(UBound(deltaxyarr, 1), UBound(deltaxyarr, 2)).Value = deltaxyarr 
関連する問題