Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default For Each Range in Worksheet

Here is how my data is laid out. I have 4 ranges on a sheet. The
first range is B9:I21, the second range is K9:R21, the third is
B32:I44 and the fourth is K32:R44. Each of them is declared in the
macro. Each of these ranges ere exactly the same. 1st column is
date, 2nd is output, third is Hours. I am currently doing a "for each
i in rng" to look at each i and determine if the date value is found
on a seperate workbook. Each range has a different column to lookup
on the seperate workbook. So now to the question.

Is there away to do a for each range in worksheet like you can do for
for each i in range?
Is there away to tell what rng your i is currently in? (if it were in
the first range I could specify which column on the seperate workbook,
where the data is stored, to look at)

Sorry this was so lengthy,
Jay
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default For Each Range in Worksheet

One way is to assign a Name to each of the ranges, say alpha, beta, gamma,
delta
Then something like:

Sub dural()
s = "alpha,beta,gamma,delta"
namme = Split(s, ",")
For i = 0 To 3
Set r = Range(namme(i))
Set rbase = r(1)
For i = 1 To 34
' enter coding using an offset from rbase
Next
Next
End Sub


The outer For loops over each of the Names Ranges. The inner For loops over
the cells in that range.
--
Gary''s Student - gsnu200829


"jlclyde" wrote:

Here is how my data is laid out. I have 4 ranges on a sheet. The
first range is B9:I21, the second range is K9:R21, the third is
B32:I44 and the fourth is K32:R44. Each of them is declared in the
macro. Each of these ranges ere exactly the same. 1st column is
date, 2nd is output, third is Hours. I am currently doing a "for each
i in rng" to look at each i and determine if the date value is found
on a seperate workbook. Each range has a different column to lookup
on the seperate workbook. So now to the question.

Is there away to do a for each range in worksheet like you can do for
for each i in range?
Is there away to tell what rng your i is currently in? (if it were in
the first range I could specify which column on the seperate workbook,
where the data is stored, to look at)

Sorry this was so lengthy,
Jay

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default For Each Range in Worksheet

I'm not sure I understand what you're doing, but maybe...

Dim myRng as range
dim myArea as range
dim myCell as range
dim wks as worksheet
Dim FirstArea as boolean

set wks = worksheets("Somesheetnamehere")
with wks
set myrng = .range("b9:i21,k9:r21,b32:i44,k32:r44")
end with

firstarea = true
for each myarea in myrng.areas '4 different areas in myRng
if firstarea = true then
'do something special
'and change that flag to false
firstArea = false
end if
for each mycell in myarea.columns(1)
msgbox mycell.address(0,0)
next mycell
next myarea





jlclyde wrote:

Here is how my data is laid out. I have 4 ranges on a sheet. The
first range is B9:I21, the second range is K9:R21, the third is
B32:I44 and the fourth is K32:R44. Each of them is declared in the
macro. Each of these ranges ere exactly the same. 1st column is
date, 2nd is output, third is Hours. I am currently doing a "for each
i in rng" to look at each i and determine if the date value is found
on a seperate workbook. Each range has a different column to lookup
on the seperate workbook. So now to the question.

Is there away to do a for each range in worksheet like you can do for
for each i in range?
Is there away to tell what rng your i is currently in? (if it were in
the first range I could specify which column on the seperate workbook,
where the data is stored, to look at)

Sorry this was so lengthy,
Jay


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default For Each Range in Worksheet

I think what I am going to do is cheat. I am going to put all the
ranges on one sheet, then have the true ranges just equal that sheet.
Then I can just have the code Read Case Select i.row.

Thansk for the insite,
Jay

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
Same range, same name, different worksheet Gilbert De Ceulaer[_2_] Excel Worksheet Functions 10 October 1st 07 06:49 PM
How do i can lock more than one range in worksheet Nazr-ul-Haque Excel Discussion (Misc queries) 2 August 26th 07 03:06 PM
Using a worksheet name from a range RPH Excel Worksheet Functions 3 January 27th 06 08:40 PM
Reference the worksheet from a multiple worksheet range function ( DBickel Excel Worksheet Functions 1 May 28th 05 03:49 AM
range from worksheet ala chartwizard Will Eichert Charts and Charting in Excel 2 February 10th 05 07:31 PM


All times are GMT +1. The time now is 10:42 PM.

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

About Us

"It's about Microsoft Excel"