Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Values run out of range

Hi I'm using the following code, that places text values in a row a
specific points in the row. The problem is that sometimes the value
exceed the range of the defined range that I'm working in

The overall range is G11:CX15

But if a cell has a value greater than "" and that value is less tha
32 cells from end of the range. It will start adding values out of th
range.

Is there a way I can make the code stopanytime it tries to go beyond C
?

Thanks.

For Each cell In Range("G11:CP287")
If cell.Value "" Then
If (cell.Offset(0, -1) = "") Then
cell.Offset(0, 7).Value = "Brk"
cell.Offset(0, 14).Value = "Lun"
cell.Offset(0, 15).Value = "Lun"
cell.Offset(0, 24).Value = "Brk"

End If
End I

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Values run out of range

cell.Offset(0, 24).Value = "Brk"

? RANGE("cp1").Offset(0,24).Address
$DN$1

think you need to do some more counting; CP is too far. You can't go beyond
BZ

? RANGE("BZ1").Offset(0,24).Address
$CX$1

Also, it the overall range is G11:CX15, why do you loop G11:CP287?


Any loop G11:BZ15 or G11:BZ287

--
Regards,
Tom Ogilvy


"hotherps " wrote in message
...
Hi I'm using the following code, that places text values in a row at
specific points in the row. The problem is that sometimes the values
exceed the range of the defined range that I'm working in

The overall range is G11:CX15

But if a cell has a value greater than "" and that value is less than
32 cells from end of the range. It will start adding values out of the
range.

Is there a way I can make the code stopanytime it tries to go beyond CP
?

Thanks.

For Each cell In Range("G11:CP287")
If cell.Value "" Then
If (cell.Offset(0, -1) = "") Then
cell.Offset(0, 7).Value = "Brk"
cell.Offset(0, 14).Value = "Lun"
cell.Offset(0, 15).Value = "Lun"
cell.Offset(0, 24).Value = "Brk"

End If
End If


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Values run out of range

Sorry about that the overall range is G11:CX287

I tried to stop it at CP so it would not go beyond the range

The code creates a work shift 32 columns wide ,and the offsets add i
the breaks and lunchs. The overall range is an entire day starting a
12:00am
at 15 minute intervals until 11:45PM.

My problem is that if someone works a late shift let's say they star
at 7PM(CE11) I need to set up a break for them but not a lunch and
second break because it will go out of the range.

Thank

--
Message posted from http://www.ExcelForum.com

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
calculate values in an unlimited range of cells in a column WITHOUTalso calculating values that had previously been filtered AGAINST? yadang Excel Discussion (Misc queries) 2 October 1st 09 06:18 PM
SUMPRODUCT or SUMIF if any values in a range equal any values in another range PCLIVE Excel Worksheet Functions 3 July 15th 09 07:43 PM
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Search/Filter to find values in another range based on two cell values Andy Excel Programming 2 April 29th 04 04:08 PM


All times are GMT +1. The time now is 11:46 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"