Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add an exception rule

Here is the code I am using.


If .Cells(x, y).Value = "." _
And counter < 6 _
And need2 0 Then
.Cells(x, y).Value = "Test"


Is there a way I can have the code look forward down the row to see i
it can be placed 6 times?

There are many reasons it could come up short, and I'm trying to avoi
having an incomplete row. I want the value to appear 6 times or not a
all.

I would prefer the code to just continue on through the rows until i
can add all 6 cells again.

Thank

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Add an exception rule

Hotherps,

You could use Countif to check the row

If worksheetfunction.countif(Rows(1),".") = 6 then
...

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"hotherps " wrote in message
...
Here is the code I am using.


If .Cells(x, y).Value = "." _
And counter < 6 _
And need2 0 Then
Cells(x, y).Value = "Test"


Is there a way I can have the code look forward down the row to see if
it can be placed 6 times?

There are many reasons it could come up short, and I'm trying to avoid
having an incomplete row. I want the value to appear 6 times or not at
all.

I would prefer the code to just continue on through the rows until it
can add all 6 cells again.

Thanks


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add an exception rule

could not get that to work.

Tried this (ugly)

If .Cells(x, y).Value = "." _
And counter < 6 _
And need 0 And _
.Cells(x, y).Offset(0, 6).Value = "." And _
.Cells(x, y).Offset(0, 5).Value = "." And _
.Cells(x, y).Offset(0, 4).Value = "." And _
.Cells(x, y).Offset(0, 3).Value = "." And _
.Cells(x, y).Offset(0, 2).Value = "." And _
.Cells(x, y).Offset(0, 1).Value = "." Then
.Cells(x, y).Value = "ENG"
counter = counter + 1

almost worked but when cells below the range were null it threw off th
row

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Add an exception rule

This works for me

If WorksheetFunction.CountIf(.Range(.Cells(x, y), .Cells(x, y + 6)),
".") = 7 _
And counter < 6 _
And need 0 Then
Cells(x, y).Value = "ENG"
counter = counter + 1
End If

even with empty cells

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"hotherps " wrote in message
...
could not get that to work.

Tried this (ugly)

If .Cells(x, y).Value = "." _
And counter < 6 _
And need 0 And _
Cells(x, y).Offset(0, 6).Value = "." And _
Cells(x, y).Offset(0, 5).Value = "." And _
Cells(x, y).Offset(0, 4).Value = "." And _
Cells(x, y).Offset(0, 3).Value = "." And _
Cells(x, y).Offset(0, 2).Value = "." And _
Cells(x, y).Offset(0, 1).Value = "." Then
Cells(x, y).Value = "ENG"
counter = counter + 1

almost worked but when cells below the range were null it threw off the
row.


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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add an exception rule

Thanks Bob it does work, however I overlooked something. If the valu
"One" or "Two" is located I have to perform the same test.

So if ".", "One" or "Two" is in the next 6 cells. Then that row shoul
be skipped. It should move down one row and begin again.

Do you know how I would do this?

Thank

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add an exception rule

As written, it requires that "." be in each of the 6 cells plus the original
cell. You now seem to say to skip it if any of the 6 cells contain "." or
"one" or "two". What conditions actually have to be met to perform the
action?

--
Regards,
Tom Ogilvy

"hotherps " wrote in message
...
Thanks Bob it does work, however I overlooked something. If the value
"One" or "Two" is located I have to perform the same test.

So if ".", "One" or "Two" is in the next 6 cells. Then that row should
be skipped. It should move down one row and begin again.

Do you know how I would do this?

Thanks


---
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
I really need help with a rule TORIA28 Excel Worksheet Functions 4 March 9th 09 01:22 PM
If/Then Rule Honorbar Excel Discussion (Misc queries) 2 January 26th 09 05:17 PM
Create a rule Maggie Boby Excel Worksheet Functions 0 January 20th 08 07:10 PM
Validation rule nick Excel Discussion (Misc queries) 4 March 6th 06 04:57 PM
validation rule andrewm Excel Worksheet Functions 7 June 23rd 05 06:45 AM


All times are GMT +1. The time now is 06:16 AM.

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"