Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Trouble Selecting a Range in VBA

I have a routine in VBA (run from MS Access) that generates s spreadsheet and
then applies an Excel subtotal function. Once the sub totals are created I
collapse to the 2nd level. This is where I run into problems. What I want to
do is select the visible cells between a1 and my last cell so that I can
apply some formatting. I know how to get to the last cell and how to get to
the visible cells but when I try to select my range I get an error "object
does not support this method or property".

stRange = "A1:" & activecell.address

Any help you give would be much appreciated.


--
Michael Joyce
Project Management IS Analyst
Aflac - Project Management Office
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Trouble Selecting a Range in VBA

You will probably need to qualify activecell with the application.object.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"MJatAflac" wrote in message
...
I have a routine in VBA (run from MS Access) that generates s spreadsheet

and
then applies an Excel subtotal function. Once the sub totals are created I
collapse to the 2nd level. This is where I run into problems. What I want

to
do is select the visible cells between a1 and my last cell so that I can
apply some formatting. I know how to get to the last cell and how to get

to
the visible cells but when I try to select my range I get an error "object
does not support this method or property".

stRange = "A1:" & activecell.address

Any help you give would be much appreciated.


--
Michael Joyce
Project Management IS Analyst
Aflac - Project Management Office



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Trouble Selecting a Range in VBA

That did it!

Thanks a million!
--
Michal Joyce
Project Management IS Analyst
Aflac - Project Management Office


"Bob Phillips" wrote:

You will probably need to qualify activecell with the application.object.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"MJatAflac" wrote in message
...
I have a routine in VBA (run from MS Access) that generates s spreadsheet

and
then applies an Excel subtotal function. Once the sub totals are created I
collapse to the 2nd level. This is where I run into problems. What I want

to
do is select the visible cells between a1 and my last cell so that I can
apply some formatting. I know how to get to the last cell and how to get

to
the visible cells but when I try to select my range I get an error "object
does not support this method or property".

stRange = "A1:" & activecell.address

Any help you give would be much appreciated.


--
Michael Joyce
Project Management IS Analyst
Aflac - Project Management Office




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Trouble Selecting a Range in VBA


I am not sure how you have declared your StRange Variable. The
following example does work though...

Dim stRange As String

stRange = "A1:" & ActiveCell.Address
Debug.Print stRange
Range(stRange).Select

I assumed you were using a string and not a Range Object. Hope that
helps

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Trouble Selecting a Range in VBA

You're right, I was using a string.
I just had to qualify it more.

dim stRange as string
stRange = "a1:" & xlApp.ActiveCell.Address
--
Michal Joyce
Project Management IS Analyst
Aflac - Project Management Office


"Mark" wrote:


I am not sure how you have declared your StRange Variable. The
following example does work though...

Dim stRange As String

stRange = "A1:" & ActiveCell.Address
Debug.Print stRange
Range(stRange).Select

I assumed you were using a string and not a Range Object. Hope that
helps




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Trouble Selecting a Range in VBA

I'm not sure what code you used to (unsuccessfully) try to select your range,
but when I used your statement:

stRange = "A1:" & activecell.address

and then:

range(stRange).Select

the range was selected just fine.

"MJatAflac" wrote:

I have a routine in VBA (run from MS Access) that generates s spreadsheet and
then applies an Excel subtotal function. Once the sub totals are created I
collapse to the 2nd level. This is where I run into problems. What I want to
do is select the visible cells between a1 and my last cell so that I can
apply some formatting. I know how to get to the last cell and how to get to
the visible cells but when I try to select my range I get an error "object
does not support this method or property".

stRange = "A1:" & activecell.address

Any help you give would be much appreciated.


--
Michael Joyce
Project Management IS Analyst
Aflac - Project Management Office

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with selecting multiple ranges of data markag Excel Worksheet Functions 2 June 23rd 06 04:35 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Trouble selecting chart in macro Jeff Excel Programming 6 April 15th 06 01:31 AM
trouble selecting a named cell john foster[_2_] Excel Programming 3 February 16th 06 11:54 AM
Trouble Naming Range Michael Smith Excel Programming 3 February 24th 05 05:46 PM


All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"