helpneeded2
Board Regular
- Joined
- Jun 25, 2021
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
I have very little understanding of VBA and am trying to modify some existing code.
The cell in C9 of my sheet contains a file name reference.
The current code has 3 references to C9:
path_ = ThisWorkbook.Worksheets("Settings").Range("C9").Value
ThisWorkbook.Worksheets("Settings").Range("C9").Value = 0
ThisWorkbook.Worksheets("Settings").Range("C9").Value = .SelectedItems(1)
Ideally I just want to set C9 to a variable, so that I only have to change the reference in 1 area if needed.
I have tried a couple different ways, but cannot get it to work due to my limited understanding of VBA.
Could someone please advise if this can be done, and how?
This was what I last tried that did not work:
Dim fileLocation As Range
fileLocation = ThisWorkbook.Sheets("Settings").Range("C9").Range
path_ = ThisWorkbook.Worksheets("Settings").fileLocation.Value
This results in an error
The cell in C9 of my sheet contains a file name reference.
The current code has 3 references to C9:
path_ = ThisWorkbook.Worksheets("Settings").Range("C9").Value
ThisWorkbook.Worksheets("Settings").Range("C9").Value = 0
ThisWorkbook.Worksheets("Settings").Range("C9").Value = .SelectedItems(1)
Ideally I just want to set C9 to a variable, so that I only have to change the reference in 1 area if needed.
I have tried a couple different ways, but cannot get it to work due to my limited understanding of VBA.
Could someone please advise if this can be done, and how?
This was what I last tried that did not work:
Dim fileLocation As Range
fileLocation = ThisWorkbook.Sheets("Settings").Range("C9").Range
path_ = ThisWorkbook.Worksheets("Settings").fileLocation.Value
This results in an error