![]() |
Select multiple ranges using cells property
I will be very grateful for the code to select two ranges at the same time.
I am formatting these ranges with borders etc and rather than do each one in turn would like to do them at the same time. The two ranges are as below. Range(Cells(5, 4), Cells(intRows, 5)) Range(Cells(5, 6), Cells(intRows, 7)) Everything I have tried selects the whole area and not separately, using D5 etc is simple but as this is dynamic I need to use the Cells property many thanks -- with kind regards Spike |
Select multiple ranges using cells property
Try the below...
intRows = 10 Range(Range(Cells(5, 4), Cells(intRows, 5)).Address & "," & _ Range(Cells(5, 6), Cells(intRows, 7)).Address).BorderAround Weight:=xlThin -- Jacob "Spike" wrote: I will be very grateful for the code to select two ranges at the same time. I am formatting these ranges with borders etc and rather than do each one in turn would like to do them at the same time. The two ranges are as below. Range(Cells(5, 4), Cells(intRows, 5)) Range(Cells(5, 6), Cells(intRows, 7)) Everything I have tried selects the whole area and not separately, using D5 etc is simple but as this is dynamic I need to use the Cells property many thanks -- with kind regards Spike |
Select multiple ranges using cells property
spot on. Many thanks much appreciated
-- with kind regards Spike "Jacob Skaria" wrote: Try the below... intRows = 10 Range(Range(Cells(5, 4), Cells(intRows, 5)).Address & "," & _ Range(Cells(5, 6), Cells(intRows, 7)).Address).BorderAround Weight:=xlThin -- Jacob "Spike" wrote: I will be very grateful for the code to select two ranges at the same time. I am formatting these ranges with borders etc and rather than do each one in turn would like to do them at the same time. The two ranges are as below. Range(Cells(5, 4), Cells(intRows, 5)) Range(Cells(5, 6), Cells(intRows, 7)) Everything I have tried selects the whole area and not separately, using D5 etc is simple but as this is dynamic I need to use the Cells property many thanks -- with kind regards Spike |
Select multiple ranges using cells property
When you have more ranges; to be selected dynamically ..you should be able to
have a loop to build the address string..separated by comma and then use that with Range() as below strAddress = "D5:E10,F5:G10,..,..,..,.." Range(strAddress).Select -- Jacob "Jacob Skaria" wrote: Try the below... intRows = 10 Range(Range(Cells(5, 4), Cells(intRows, 5)).Address & "," & _ Range(Cells(5, 6), Cells(intRows, 7)).Address).BorderAround Weight:=xlThin -- Jacob "Spike" wrote: I will be very grateful for the code to select two ranges at the same time. I am formatting these ranges with borders etc and rather than do each one in turn would like to do them at the same time. The two ranges are as below. Range(Cells(5, 4), Cells(intRows, 5)) Range(Cells(5, 6), Cells(intRows, 7)) Everything I have tried selects the whole area and not separately, using D5 etc is simple but as this is dynamic I need to use the Cells property many thanks -- with kind regards Spike |
Select multiple ranges using cells property
how do i select two individual cells using the cells propertly to format in
the same way. ie Range (Cells(5, 4) and Range(Cells(5, 5) so that i get a border line around each one -- with kind regards Spike "Spike" wrote: I will be very grateful for the code to select two ranges at the same time. I am formatting these ranges with borders etc and rather than do each one in turn would like to do them at the same time. The two ranges are as below. Range(Cells(5, 4), Cells(intRows, 5)) Range(Cells(5, 6), Cells(intRows, 7)) Everything I have tried selects the whole area and not separately, using D5 etc is simple but as this is dynamic I need to use the Cells property many thanks -- with kind regards Spike |
Select multiple ranges using cells property
Try
Range(Cells(5, 4).Address & "," & Cells(5, 5).Address).BorderAround _ Weight:=xlThin -- Jacob "Spike" wrote: how do i select two individual cells using the cells propertly to format in the same way. ie Range (Cells(5, 4) and Range(Cells(5, 5) so that i get a border line around each one -- with kind regards Spike "Spike" wrote: I will be very grateful for the code to select two ranges at the same time. I am formatting these ranges with borders etc and rather than do each one in turn would like to do them at the same time. The two ranges are as below. Range(Cells(5, 4), Cells(intRows, 5)) Range(Cells(5, 6), Cells(intRows, 7)) Everything I have tried selects the whole area and not separately, using D5 etc is simple but as this is dynamic I need to use the Cells property many thanks -- with kind regards Spike |
Select multiple ranges using cells property
thanks. That was the one combination i had not tried!
-- with kind regards Spike "Jacob Skaria" wrote: Try Range(Cells(5, 4).Address & "," & Cells(5, 5).Address).BorderAround _ Weight:=xlThin -- Jacob "Spike" wrote: how do i select two individual cells using the cells propertly to format in the same way. ie Range (Cells(5, 4) and Range(Cells(5, 5) so that i get a border line around each one -- with kind regards Spike "Spike" wrote: I will be very grateful for the code to select two ranges at the same time. I am formatting these ranges with borders etc and rather than do each one in turn would like to do them at the same time. The two ranges are as below. Range(Cells(5, 4), Cells(intRows, 5)) Range(Cells(5, 6), Cells(intRows, 7)) Everything I have tried selects the whole area and not separately, using D5 etc is simple but as this is dynamic I need to use the Cells property many thanks -- with kind regards Spike |
All times are GMT +1. The time now is 07:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com