Ejemplo 1: excel vba seleccionar varios rangos
Sub ClearRanges()
' Using the Range Property
Worksheets("Sheet1").Range("C5:D9,G9:H16,B14:D18").ClearContents
Range("MyRange, YourRange, HisRange").ClearContents
' Using the Union Method
Dim myMultipleRange As Range
Set myMultipleRange = Union(Sheets("Sheet1").Range("A1:B2"), _
Sheets("Sheet1").Range("C3:D4"))
myMultipleRange.ClearContents
End Sub
Ejemplo 2: rangos de combinación de excel vba
With Sheet1
Set rng1 = .Range("A1:A3")
Set rng2 = .Range("C1:C3")
'This combines the two separate ranges, so select A1, A2, A3, C1, C2, C3
set newRng = Union(rng1, rng2)
'This combines the two ranges in the same way as when using "A1:C3",
'so including the cells from column B
set newRng = .Range(rng1, rng2)
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)