Get and Transform aka Power Query Assistance (1 Viewer)

JMongi

Active member
Local time
Today, 13:40
Joined
Jan 6, 2021
Messages
492
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, 10:40
Joined
Mar 14, 2017
Messages
5,386
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, 10:40
Joined
Mar 14, 2017
Messages
5,386
Compile error or runtime? What's the error?
 

JMongi

Active member
Local time
Today, 13:40
Joined
Jan 6, 2021
Messages
492
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