tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,210
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
So I was wondering if there is a way to reference thing like sheet names and ranges outside of the macro and still have it know what I mean?
for examples
This is an example of how I might currently write a macro (I know its not real its for example only)
Then I start a new macro and have to do these bit all over again
is there a way I could have all this in a macro or somewhere and every macro I write in the document know that Cont =
<strike></strike>
So I was wondering if there is a way to reference thing like sheet names and ranges outside of the macro and still have it know what I mean?
for examples
This is an example of how I might currently write a macro (I know its not real its for example only)
Code:
Sub Example1()
Dim sht As Worksheet
Dim mybook As Workbook
Dim total_ch As Variant
Set mybook = ThisWorkbook
Set Cont = ThisWorkbook.Sheets("Control")
[LEFT][COLOR=#222222][FONT=Verdana]Set Sale = ThisWorkbook.Sheets("Sales")[/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana]Set Chart = ThisWorkbook.Sheets("Charts")[/FONT][/COLOR][/LEFT]
Impot = "I6"
FileLoc = "E4"
total_tl = SimCont.Range(Teams2Impot).Value
Range("A2") = total_tl
End Sub
Then I start a new macro and have to do these bit all over again
Dim sht As Worksheet
Dim mybook As Workbook
Dim total_ch As Variant
Set mybook = ThisWorkbook
Set Cont = ThisWorkbook.Sheets("Control")
Impot = "I6"
FileLoc = "E4"
Dim mybook As Workbook
Dim total_ch As Variant
Set mybook = ThisWorkbook
Set Cont = ThisWorkbook.Sheets("Control")
Set Sale = ThisWorkbook.Sheets("Sales")
Set Chart = ThisWorkbook.Sheets("Charts")
Set Chart = ThisWorkbook.Sheets("Charts")
Impot = "I6"
FileLoc = "E4"
is there a way I could have all this in a macro or somewhere and every macro I write in the document know that Cont =
ThisWorkbook.Sheets("Control")??? etc.
please help if you can
Tony
<strike></strike>please help if you can
Tony