ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Question on how to reference multiple cells in VBA (https://www.excelbanter.com/excel-programming/365469-question-how-reference-multiple-cells-vba.html)

[email protected]

Question on how to reference multiple cells in VBA
 
I am trying to select cells in a row that are not contiguous. Example
in row 15 i want select C, E, J, I, and K. I used the record macro
function to get

Range("C15,E15,G15,I15,K15").Select

but it will not always be row 15. I am adding rows to a spreadsheet via
a custom written macro and I am trying to select the different cells to
format them.

Thank you for any help,

Louis Markham


Tim Williams

Question on how to reference multiple cells in VBA
 
One way

Range("C" & i & ",E" & i & ",G" & i & ",I" & i & ",K" & i).Select

where i has your row number

Tim

wrote in message oups.com...
I am trying to select cells in a row that are not contiguous. Example
in row 15 i want select C, E, J, I, and K. I used the record macro
function to get

Range("C15,E15,G15,I15,K15").Select

but it will not always be row 15. I am adding rows to a spreadsheet via
a custom written macro and I am trying to select the different cells to
format them.

Thank you for any help,

Louis Markham




Louis Markham

Question on how to reference multiple cells in VBA
 
Thanks a ton!!!!!

M


Tim Williams wrote:
One way

Range("C" & i & ",E" & i & ",G" & i & ",I" & i & ",K" & i).Select

where i has your row number

Tim

wrote in message oups.com...
I am trying to select cells in a row that are not contiguous. Example
in row 15 i want select C, E, J, I, and K. I used the record macro
function to get

Range("C15,E15,G15,I15,K15").Select

but it will not always be row 15. I am adding rows to a spreadsheet via
a custom written macro and I am trying to select the different cells to
format them.

Thank you for any help,

Louis Markham




All times are GMT +1. The time now is 01:03 PM.

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