Active Cell

P

Paul Skinner

Hi,
Running Excel X, Panther 10.3.7
When I filter a database (Not as a list) I need the active cell to show at
the first cell of the filtered data. This is needed for my macro's to
function. I need to select this cell in my macro. Help!!
 
J

JE McGimpsey

Paul Skinner said:
When I filter a database (Not as a list) I need the active cell to show at
the first cell of the filtered data. This is needed for my macro's to
function. I need to select this cell in my macro. Help!!

First, one almost never needs to select *anything* in a macro. Using
Range objects directly makes your code smaller, faster, and, IMO, easier
to maintain.

I don't know what you're doing, so I'll give you a generic example.
Instead of something like

Range("A2:A65536").SpecialCells(xlCellTypeVisible)(1).Select
Selection.EntireRow.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste

Use the one line statement (the " _", or space-underscore, indicates
that the code line continues on the next screen line):

Range("A2:A65536").SpecialCells(xlCellTypeVisible)(1).EntireRow.Copy _
Destination:=Sheets("Sheet2").Range("A1")
 
P

Paul Skinner

It worked this is what I needed SpecialCells(xlCellTypeVisible)(1).Select
Your good Very good. Thanks and a great new year to all. Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top