Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Range in VBA
Hello,
this is my range: Set myRng = .Range("E3", .Cells(.Rows.Count, "E").End(xlUp)) It is possible to set my range to jump 2 rows. Example. E3, E5,E7,E9 INSTEAD E3,E4,E5,E6 -- Regards, Jeff |
#2
|
|||
|
|||
One way:
Dim i As Long Set myRng = .Cells(3, 5) For i = 5 To .Cells(.Rows.Count, 5).End(xlUp).Row Step 2 Set myRng = Union(myRng, .Cells(i, 5)) Next i End With In article , "Jeff" wrote: Hello, this is my range: Set myRng = .Range("E3", .Cells(.Rows.Count, "E").End(xlUp)) It is possible to set my range to jump 2 rows. Example. E3, E5,E7,E9 INSTEAD E3,E4,E5,E6 |
#3
|
|||
|
|||
Depending on what you want to do, maybe you could just loop through your cells
and keep track if the row is even or odd. for each mycell in myrng.cells if mycell.row mod 2 = 0 then 'it's even, do nothing else 'do the work end if next mycell Or you could build the range the way you want it: dim myRng as range dim LastRow as long dim iCtr as long with activesheet set myrng = .range("e3") lastrow = .cells(.rows.count,"E").end(xlup).row for ictr = 5 to lastrow step 2 'start with 5 since myrng already has E3 in it set myrng = union(myrng, .cells(ictr,"E")) next ictr end with Jeff wrote: Hello, this is my range: Set myRng = .Range("E3", .Cells(.Rows.Count, "E").End(xlUp)) It is possible to set my range to jump 2 rows. Example. E3, E5,E7,E9 INSTEAD E3,E4,E5,E6 -- Regards, Jeff -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help PLEASE! Not sure what answer is: Match? Index? Other? | Excel Worksheet Functions | |||
Match function...random search? | Excel Worksheet Functions | |||
How do I edit a Named Range using macro's | Excel Worksheet Functions | |||
Cannot Expand Named Range - when size of the Range exceeds | Excel Discussion (Misc queries) | |||
Define a range based on another named range | Excel Worksheet Functions |