ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   With End using multiple ranges (https://www.excelbanter.com/excel-programming/358997-end-using-multiple-ranges.html)

ExcelMonkey

With End using multiple ranges
 
Is it possibe to use With End stmts on muliple ranges. Below I am adjsuting
the properties of one range. If I want to do this to two separate ranges,
can I append the With part of the statement to also take the second range
("SecondCell"). Thanks

With Range("FirstCell")
.Interior.Pattern = xlGray50
.Locked = True
.FormulaHidden = False
.Validation.InCellDropdown = False
End With

Nick Hodge

With End using multiple ranges
 
Try

With Range("FirstCell, SecondCell")
'do something here
End With

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"ExcelMonkey" wrote in message
...
Is it possibe to use With End stmts on muliple ranges. Below I am
adjsuting
the properties of one range. If I want to do this to two separate ranges,
can I append the With part of the statement to also take the second range
("SecondCell"). Thanks

With Range("FirstCell")
.Interior.Pattern = xlGray50
.Locked = True
.FormulaHidden = False
.Validation.InCellDropdown = False
End With




ExcelMonkey

With End using multiple ranges
 
Perfect, thanks.


"Nick Hodge" wrote:

Try

With Range("FirstCell, SecondCell")
'do something here
End With

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"ExcelMonkey" wrote in message
...
Is it possibe to use With End stmts on muliple ranges. Below I am
adjsuting
the properties of one range. If I want to do this to two separate ranges,
can I append the With part of the statement to also take the second range
("SecondCell"). Thanks

With Range("FirstCell")
.Interior.Pattern = xlGray50
.Locked = True
.FormulaHidden = False
.Validation.InCellDropdown = False
End With






All times are GMT +1. The time now is 05:23 PM.

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