VBA Editor not autocompleting

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
704
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Why is my VBA Excel editor not autocompleting while I type the code?
For example: if I type "Selection". I'll usually expect to see the list of things I can do with it.
Maybe I disabled any setting?

Thanks
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Okay, but the OP did not mention that it is working with a chart sheet. And my example is focused on a sheet.

The OP asked about intellisense re Selection, not ActiveSheet. I was merely commenting upon the example you posted.
 
Upvote 0
The OP asked about intellisense re Selection, not ActiveSheet. I was merely commenting upon the example you posted.

Thanks for the observation.

Everything is about intellisense, it is to show another example of that and to correctly declare the variables.
 
Last edited:
Upvote 0
Thanks all.
Intellisense does not seem to work with "Selection.", "Activesheet.", "Sheets(1).", "Cells(1,1).".
I suppose that in Word the minimum selection (if you don't selected anything else) is the character right to the cursor position, in Excel is the Activecell, so I think that the VBA can know what is selected.
In conclusion, since sometimes I need the intellisense assistance for programming macros and there's this easy workaround, I will correctly declare variable instead of direct using "Sheets(x).", "Selection." or "Cells(x,y).", like:
Code:
Sub MyNewMacro

Dim, oRng as Range, oSheet as Worksheet

Set oRng=Selection.range ' or Cells(1,1) for example
Set oSheet=Sheets(1)

Debug.print oRng.cells.count
Debug.print oSheet.name

End Sub
 
Last edited:
Upvote 0
I suppose that in Word the minimum selection (if you don't selected anything else) is the character right to the cursor position, in Excel is the Activecell, so I think that the VBA can know what is selected.

No, in Excel the selection could be a chart, or a shape/control for example. Activecell will give intellisense because it's always a Range. Selection could be a number of things that are not ranges, which is why it returns an Object, and that is why you don't get Intellisense. Equally, as has been said, Activesheet - or Sheets(n) - is not necessarily a worksheet, so again it returns an Object and you don't get Intellisense. Cells is the one anomaly there as far as I can see.
 
Upvote 0
Sid's posts in that thread are rife with errors.

It returns a handle to that Range.

For example

Code:
Sub Sample()
  Dim rng As Range
  
  Set rng = Range.Cells(1, 1)
  
  MsgBox rng.Address '<~~ This will give you the address of the range
  MsgBox rng.Value '<~~ This will give you the value of the range
End Sub

That doesn't compile.

IntelliSense is not available for generic object types and .Cell() is a generic object type. Same goes for ActiveSheet. You will not get IntelliSense for Activesheet but will get it for Sheets("Sheet1")

There is no ".Cell", and Cells always returns a range, and you don't get Intellisense for Sheets() (because it can return various objects) or Worksheets() (because it can return a worksheet object or a Worksheets collection, which have different properties and methods). Nothing in that sentence is correct.
 
Upvote 0
Interesting, but doesn't Colin's post suggest that Cells(whatever) could return something other than an Range object? What might that be, and how?
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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