'How do I declare a variable or const for a module
how do I declare a variable (or constant?), so only the procedures in the current module can read it? For example:
Option Explicit
Private const dataPath as String = "..."
Private const dataFile as String = "File.xlsm"
Private const dataSheet as String = "Sheet1"
Sub GetData()
Dim WB as Workbook
Dim wsSet as Worksheet
Set WB = Workbooks(ThisWorkbook.Name)
Set wsSet = WB.Worksheets("Settings")
Workbooks.Open Filename:=dataPath & "\" & dataFile
Workbooks(dataFile).Sheets(dataSheet).Range("A:A").Copy
wsSet.Range("D:D").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Workbooks(dataFile).Close SaveChanges:=False
WB.Save
MsgBox "Done.", vbOkOnly, "Well done"
Exit Sub
Is that the correct way? Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
