question about a class module test

ajetrumpet

Banned for being rude
Joined
Apr 12, 2008
Messages
569
Office Version
  1. 365
  2. 2016
  3. 2007
Platform
  1. Windows
hello guys,

I'm running a test on the class module CCell described here:

http://ptgmedia.pearsoncmg.com/images/9780321508799/samplepages/0321508793_Sample.pdf

When I copied that code into a class module in Excel, I got a few errors, so my first thought is that those guys are not correct in their coding. But the purpose of this test of mine is to tell others whether writing classes is worth it a lot of time, outside of being standard for programming practice. One of the errors I think I noticed is the Sub Analyze(). If I run the msgbox code they instruct me to in the PDF and I copy the code exactly like they have it in the PDF into the VB editor, I get this error:

expected function or variable.jpg

but if Analyze() is changed to a function, I get "object variable not set" error:

object variable not set.jpg

can someone spot the issue, regardless of whether it is me or them? I don't write many class modules, nor have I ever because most of my stuff has been done through built-in functions and interface work. thanks!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Worked perfectly for me

Code in a Standard Module

VBA Code:
Public Sub Analyse()
    Dim clsCell As CCell
    
    Set clsCell = New CCell
    Set clsCell.Cell = Application.ActiveCell
    clsCell.Analyse
    MsgBox clsCell.DescriptiveCellType
End Sub


M.
 
Upvote 0
Marcelo,

aways down in that PDF, they instruct you to run what you did from another procedure. I did that instead of what you did. Let me try your way and get back to you. I think there's bad instructions in the subsequent pages of that PDF.
 
Upvote 0
Marcelo,

aways down in that PDF, they instruct you to run what you did from another procedure. I did that instead of what you did. Let me try your way and get back to you. I think there's bad instructions in the subsequent pages of that PDF.

My code is based on instructions in page 168, Listing 7-2

M.
 
Upvote 0
I see what you did Marc. I got it to work. you just changed the sub name. thanks. this is solved.
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,772
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top