#1   Report Post  
Jeff
 
Posts: n/a
Default 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   Report Post  
JE McGimpsey
 
Posts: n/a
Default

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   Report Post  
Dave Peterson
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help PLEASE! Not sure what answer is: Match? Index? Other? baz Excel Worksheet Functions 7 September 3rd 05 03:47 PM
Match function...random search? Les Excel Worksheet Functions 10 July 28th 05 11:54 AM
How do I edit a Named Range using macro's behmer Excel Worksheet Functions 2 July 26th 05 09:02 PM
Cannot Expand Named Range - when size of the Range exceeds Snig Excel Discussion (Misc queries) 1 July 7th 05 01:46 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"