ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Select a certain number of cells in a row (https://www.excelbanter.com/excel-discussion-misc-queries/51593-select-certain-number-cells-row.html)

Dolphinv4

Select a certain number of cells in a row
 
Hi,

I'd like to have the macro to select row 5 to 10 in the active column. May I
know what is the VB code to write?

Regards,
Valerie

Dave Peterson

Select a certain number of cells in a row
 
maybe...

dim myRng as range
dim myCol as long

with activesheet
mycol = activecell.Column
set myrng = .range(.cells(5,mycol),.cells(10,mycol))
end with

myrng.select

=======
or

with activesheet
.cells(5,activecell.column).resize(6).select
end with

I'm not quite sure why you want to select that range. But for the most part, if
you act directly on the range (and avoid .selects), you're code will work faster
and be easier to modify.

Dolphinv4 wrote:

Hi,

I'd like to have the macro to select row 5 to 10 in the active column. May I
know what is the VB code to write?

Regards,
Valerie


--

Dave Peterson


All times are GMT +1. The time now is 12:35 PM.

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