-1

ユーザーにファイルを要求し、最初のシートの内容をコピーするVBAを作成しています(シート名はデフォルトではなく、スペースが含まれています)..その後、特定の列を削除する必要があります..必要な行から特定のテキストを含む行を削除する (大文字と小文字が区別されます)

今できることはファイルをロードすることだけですが、データをアクティブなワークシートにコピーする方法がわかりません!!

FileToOpen = Application.GetOpenFilename _
(Title:="Please Choose the RTCM File", _
FileFilter:="Excel Files *.xls (*.xls),")
''
If FileToOpen = False Then
MsgBox "No file specified.", vbExclamation, "Duh!!!" ' Notification that nothing is chosen
Exit Sub
Else ' Load the file, copy the first sheet and paste it in active sheet ...

End If
4

1 に答える 1

0

お役に立てれば。このコードは、既にアクティブなシートにデータを貼り付けます。特定のシートにデータを貼り付けたい場合は、Activesheet を Sheets("Sheetname") に置き換えることができます。

貼り付けるデータはA列~Z列のみと想定していますので、必要に応じて変更してください。

FileToOpen = Application.GetOpenFilename _
(Title:="Please Choose the RTCM File", _
FileFilter:="Excel Files *.xls (*.xls),")

If FileToOpen = False Then
    MsgBox "No file specified.", vbExclamation, "Duh!!!" ' Notification that nothing is chosen
    Exit Sub
Else ' Load the file, copy the first sheet and paste it in active sheet ...
    ThisWorkbook.Activate
    ThisWorkbook.ActiveSheet.Range("A1:Z65536").ClearContents
    Workbooks(FileToOpen).Activate
    lrow=Workbooks(FileToOpen).Sheets("Sheet1").Cells(65536,1).End(xlUp).Row
    Workbooks(FileToOpen).Sheets("Sheet1").Range("A1:Z" & lrow).Copy
    ThisWorkbook.Activate
    ThisWorkbook.ActiveSheet.Range("A1").PasteSpecial xlPasteValues
End If
于 2013-01-31T09:22:57.813 に答える