2017-02-21 8 views
0

これで、同じ名前を持つすべてのワークシートを選択し、ブック内の特定のシートの前に移動するマクロを完成させようとしています。ユーザーは、これらの名前を持つページをいくつでも追加できます。そのため、配列関数を使用して移動することはできません。これは私がこれまで持っているものです:ブック内の同じ名前のページを移動する

あなたが使用すること
Sub Copier() 

Application.DisplayAlerts = False 
Application.ScreenUpdating = False 


Dim x As Integer 
x = InputBox("Enter Number of Additional Features") 
For numtimes = 1 To x 
ActiveWorkbook.Sheets(Array("Data Collection", "Findings", "Visual Findings")).Copy _ 
Before:=ActiveWorkbook.Sheets("Final Results") 
    'Allows user to create as many pages as necessary 

Dim ws As Worksheet, flg As Boolean 
For Each ws In Worksheets 
    If (ws.Name) Like "*Data Collection*" Then 
     ws.Select Not flg 
     flg = True 
End If 
Next 
'Selects all sheets for "Data Collection" 
'Now I need to move all of those selected before a certain sheet at the 
    beginning of the workbook 
'I cant seperate the copy functions because some formulas from data collection have to carry 
over to the other copied sheets 

'Sheet2.Activate 
Application.DisplayAlerts = True 
Application.ScreenUpdating = True 
End Sub 
+2

どのようにして、「類似名」を定義していますか? 「ビジュアルファインディング」と同様の「ファインディング」?おそらく、他のすべてのシートの後に特定のページ(「最終結果」?)*を追加したいと言ったほうがよいでしょうか? – BruceWayne

+0

ユーザーが作成したデータ収集ページは、レポートの先頭近くに移動する必要があります。作成されたページの前後に他のページがあります。すべてのデータ収集ページを最初に誘導しようとしているので、ユーザーはレポート全体を調べなくてもそれらを記入できます。 –

答えて

0

Dim sheetNames As String 
Dim ws As Worksheet, flg As Boolean 
For Each ws In Worksheets 
    If ws.Name Like "*Data Collection*" Then sheetNames = sheetNames & "|" 
Next 

If sheetNames <>"" Then ActiveWorkbook.Sheets(Split(Left(sheetNames, Len(sheetNames) - 1),"|").Move Before:=ActiveWorkbook.Sheets("Final Results") 
+0

私は別の方向に行くそれを考え出し:整数 薄暗いは、x = InputBox関数(「追加機能の数を入力します」)numtimes = 1 xにActiveWorkbook.Sheets(アレイ用 文字列 として整数 薄暗いyとxと –

+0

薄暗いnumtimesを( "データ収集"、 "ILI vs NDE"、 "スクリーンショット"))コピー_ 前:= ActiveWorkbook.Sheets( "MPI") numtimes> 1の場合 y = "データ収集&lt; "&gt; &&)" 他の場合:=ワークシート(y)= 次のように入力してください: 次のように入力してください: –

関連する問題