Get and Transform aka Power Query Assistance (1 Viewer)

JMongi

Active member
Local time
Today, 09:41
Joined
Jan 6, 2021
Messages
802
I know it might be tough to answer without a code snippet, but, when I first went to cleanup this code I tried to set up the mtr, con and wb as their objects. i.e. Dim mtr as worksheet.

It didn't like it. Anyone know why? Edit: Didn't like it at the point of set mtr = Worksheets("Master").
 

Isaac

Lifelong Learner
Local time
Today, 06:41
Joined
Mar 14, 2017
Messages
8,738
As far as activate goes, is it even needed in VBA? Shouldn't all the commands work without the sheet being active?
Precisely.

The problem comes when people do things like this:

Range("A1").Value="Something"

The only way that works (even at a poor level), is to Activate the sheet (where you want range A1), first. Thus many people get in the habit of Activating a particular Worksheet, and then using otherwise unqualified references, like Range and Cells, and crossing their fingers that it works.

You're right - I've not really come across any reason to use Select and Activate, and they shouldn't be used.
 

Isaac

Lifelong Learner
Local time
Today, 06:41
Joined
Mar 14, 2017
Messages
8,738
Compile error or runtime? What's the error?
 

JMongi

Active member
Local time
Today, 09:41
Joined
Jan 6, 2021
Messages
802
Sorry, I know I gave less than useful info. Give a few minutes to button something up and I should be free to tackle this and clean up the code. Time frame (thankfully) seems to have decompressed.
 

Users who are viewing this thread

Top Bottom