Esrasnatas
New Member
Hello,
I have done some searching on this and cannot find any answers.
I have a workbook that has several sheets and I import from another workbook several more sheets.
I was tidying up my code by starting to use to use sheet codenames, rather than the sheet name, to make it a bit more robust.
The issue I have is that when I run debug compile, I get a compile error "variable not defined" wherever I have referenced the 2nd workbooks codenames.
I realise this is due to the sheets not existing in the workbook at the current time, but they will exist once the code starts running. Is there any way to get the
code running, short of turning off "Option Explicit"?
I've tried creating the variable as variants, string, object, worksheet but this does not work.
E.g.
Dim Sht_58_Data As Worksheet
Sht_58_Data.Activate
Been playing with VBA for a while but use it infrequently so my code starts messy, then when I get time I go back to try and tidy it up as I learn more.
I have done some searching on this and cannot find any answers.
I have a workbook that has several sheets and I import from another workbook several more sheets.
I was tidying up my code by starting to use to use sheet codenames, rather than the sheet name, to make it a bit more robust.
The issue I have is that when I run debug compile, I get a compile error "variable not defined" wherever I have referenced the 2nd workbooks codenames.
I realise this is due to the sheets not existing in the workbook at the current time, but they will exist once the code starts running. Is there any way to get the
code running, short of turning off "Option Explicit"?
I've tried creating the variable as variants, string, object, worksheet but this does not work.
E.g.
Dim Sht_58_Data As Worksheet
Sht_58_Data.Activate
Been playing with VBA for a while but use it infrequently so my code starts messy, then when I get time I go back to try and tidy it up as I learn more.