こんにちは私はVBAマクロを作成しようとしています。このマクロは、Excelファイルをブラウズしてからファイルを操作します。次のように私が書いたコードは次のとおりです。VBAブラウズファイルと操作を作成
Option Explicit
Sub SelctFile()
Dim intChoice As Integer
Dim strPath As String
Dim i As Integer
'allow the user to select multiple files
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = True
'make the file dialog visible to the user
intChoice = Application.FileDialog(msoFileDialogOpen).Show
'determine what choice the user made
If intChoice <> 0 Then
'get the file path selected by the user
For i = 1 To Application.FileDialog(msoFileDialogOpen _
).SelectedItems.Count
strPath = Application.FileDialog(msoFileDialogOpen _
).SelectedItems(i)
'print the file path to sheet 1
Cells(i + 1, 2) = strPath
Next i
End If
End Sub
Sub ISIN()
Dim MSReport As Variant
MSReport = Range("B2").Value
Set MSReport = Workbooks.Open(Filename:="MSReport")
Range("W3:W2500").Formula = "=IF(G3="""","""",BDP(G3&"" Equity"",""ID_ISIN""))"
End Sub
最初のサブSelectFileは、ファイルを選択し、私は、セルB2にファイルパスを持っています。だから、Sub ISINのセルB2からのパスを使用したいと思います。
アドレスを書き込むと動作しますが、マクロが自動的にアドレスを取得する必要があります。
また、別のワークシートを開くことなく変更がmadaである可能性があります。
_ "とは何を意味しますか?マクロには自動的にアドレスが必要です。 – user3598756