▽1
●
きゃづみぃ ●100ポイント ベストアンサー |
取得した値をエクセルに貼り付けやすいようにしてみました。
Sub number_tran() Dim i As Integer Dim data(5, 11) As Double Dim intYLine As Integer, intXLine As Integer Dim objFirstFindCell As String Dim objFindCell As Object, clipboardData As Object Dim k As Integer Dim s As String Set clipboardData = CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") Worksheets(1).Activate Set objFindCell = Worksheets(1).Cells.Find("apple", LookAt:=xlWhole) If Not objFindCell Is Nothing Then objFirstFindCell = objFindCell.Address i = 1 Do intYLine = objFindCell.Cells.Row intXLine = objFindCell.Cells.Column data(1, i) = Cells(intYLine, intXLine + 1).Value data(2, i) = Cells(intYLine + 1, intXLine + 1).Value data(3, i) = Cells(intYLine + 2, intXLine + 1).Value i = i + 1 Set objFindCell = Cells.FindNext(objFindCell) Loop Until objFindCell.Address = objFirstFindCell s = "" For k = 1 To i - 1 s = s & data(1, k) & Chr(9) s = s & data(2, k) & Chr(9) If k = i - 1 Then s = s & data(3, k) Else s = s & data(3, k) & Chr(9) End If Next k With clipboardData .setText s .PutInClipboard End With End If End Sub
質問の趣旨を間違えてしまいました。申し訳ありません。
エクセル等で セルを複数選択して貼り付けるのは簡単ですが、
配列でデータの並び替え変換をしてから、
クリップボードにコピーしてしたのち、
複数のセルを手動で貼り付けるような使用方法を考えています。