I have a variable filename, defined within one of the sub routines. How can i use it globally elsewhere in any other sub-routine within the same module
Sub database_create()
Dim FileFormat As String
Dim LastRow As Long
Dim i As Integer
'Find the last row.
With shPaths
LastRow = .Cells(.Rows.count, "B").End(xlUp).Row
End With
' For i = 2 To LastRow
For i = 2 To 2
conversion_importexcel Cells(i, 3).Value
Next
'Inform the user that conversion finished.
MsgBox "All files were converted successfully!", vbInformation, "Finished"
End Sub
Sub conversion_importexcel(OutPath As String)
Dim lRow As Long
Dim lCol As Long
Dim fNameAndPath As Variant
Dim filename As Variant
Dim convtexcelpath As String
Dim frstwrd As String
'convtexcelpath = WorksheetFunction.Substitute(OutPath, ".pdf", "_adobeConverted" & "." & LCase(FileExtension))
convtexcelpath = WorksheetFunction.Substitute(OutPath, ".pdf", "_Converted" & "." & "xlsx")
fNameAndPath = convtexcelpath
If fNameAndPath = False Then Exit Sub
Workbooks.Open filename:=fNameAndPath
filename = fNameAndPath
filename = (Replace(Mid(filename, InStrRev(filename, "\") + 1), ".xlsx", "") & "_database")
end sub