ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting range programmatically (https://www.excelbanter.com/excel-programming/373314-selecting-range-programmatically.html)

Barb Reinhardt

Selecting range programmatically
 
I've got the following to define a value on another worksheet and it works.

Sheets(Summary.Name).Cells(Sheets(Summary.Name).Ce lls(Rows.Count,
"A").End(xlUp).Row + 1, 1).Value = Target.Offset(0, 6 - Target.Column).Value

What I want to do is select a range including this cell up to 12 columns to
the right to put a border on it. I've tried this:

Sheets(Summary.Name).Cells(Sheets(Summary.Name).Ce lls(Rows.Count,
"A").End(xlUp).Row + 1, 12).Select

I get "Select method of range class failed"

Thanks



Bernie Deitrick

Selecting range programmatically
 
Barb,

You need to activate a sheet before you can select a range. Try:

Sheets(Summary.Name).Activate
Sheets(Summary.Name).Cells(Sheets(Summary.Name).Ce lls(Rows.Count, _
"A").End(xlUp).Row + 1, 12).Select


HTH,
Bernie
MS Excel MVP


"Barb Reinhardt" wrote in message
...
I've got the following to define a value on another worksheet and it works.

Sheets(Summary.Name).Cells(Sheets(Summary.Name).Ce lls(Rows.Count,
"A").End(xlUp).Row + 1, 1).Value = Target.Offset(0, 6 - Target.Column).Value

What I want to do is select a range including this cell up to 12 columns to
the right to put a border on it. I've tried this:

Sheets(Summary.Name).Cells(Sheets(Summary.Name).Ce lls(Rows.Count,
"A").End(xlUp).Row + 1, 12).Select

I get "Select method of range class failed"

Thanks






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com