Forum

Compile Error Durin...
 
Notifications
Clear all

Compile Error During Training

7 Posts
4 Users
0 Reactions
71 Views
(@bwaise)
Posts: 5
Active Member
Topic starter
 

Hi,

am not able to use VBA to update the dashboard, can you have a look and explain what's wrong please. I have followed the video tutorials religiously and all has been okay until now.

 

Thanks

 
Posted : 02/07/2020 11:23 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Fred,

Welcome to the forum! It's great to see you're working through the course.

The module name is missing from the Data sheet code in the sample file. In the video it shows this:

Private Sub Worksheet_Deactivate()

      ThisWorkbook.RefreshPT

End Sub

 

That should fix it. I'll update the sample Excel file in the downloads. Sorry for the hassle.

Mynda

 
Posted : 02/07/2020 7:35 pm
(@bwaise)
Posts: 5
Active Member
Topic starter
 

Thanks

 
Posted : 03/07/2020 12:59 am
(@amartin)
Posts: 2
New Member
 

Hello Mynda

I also had an error in the code.

I ran ThisWorkbook.RefreshPT  but that still gave me an error, so I ran ThisWorkbook.RefreshAll and it works.

I know this isn't very efficient as it will slow the refresh down considerably if I have a lot of data, but not sure what else to do.

Any suggestions?

Thanks in advance.

Adam

 
Posted : 08/07/2020 12:46 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Adam,

The only reason I can think that you would have this problem if you are calling ThisWorkbook.RefreshPT is if the code in the Worksheet_Deactivate() event can't see the RefreshPT sub.

In the ThisWorkbook module you should have a sub called RefreshPT ?  It should be declared like this:

Sub RefreshPT()

It shouldn't be preceded by the word Private.

If you can't get that to work please attach your workbook.

Regards

Phil

 
Posted : 08/07/2020 6:20 am
(@amartin)
Posts: 2
New Member
 

Ah Haaa, your a genius Phil, thank you.

I had this - Private Sub RefreshPT()

and removed the word 'Private' as you said, changed it to this - Sub RefreshPT()

and it works fine, thanks Phil, all good.Smile

Cheers

Adam

 
Posted : 09/07/2020 6:23 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

No worries 🙂

 
Posted : 09/07/2020 6:52 pm
Share: