Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Code not working

Here is the code I am having trouble with. It returns all "X"'s in the offset ranges, whereas there should be three "O"'s and one "", (blank).

Whe
J = range A9 and A9 value is "B"
RangerTest is a named range A1 to O1 of sheet1
RangerTest has these values: ABCDEBFGHIJBKL and O1 is blank

When I run the code the offset values a XXXXXXXXXXXXXX and the last offset
O1 is blank. The desired out come should be: XOXXXOXXXXXOXX (with the last offset blank in this example.

Sub Testx()
Dim J As String
Dim RangerTest As Range, Cell As Range
J = Range("A9").Value

For Each Cell In Range("RangerTest")
If Cell.Value = J Then Cell.Offset(5, 0).Value = "O"
If Cell.Value < J Then Cell.Offset(5, 0).Value = "X"
If Cell.Value = "" Then Cell.Offset(5, 0).Value = ""
Next

End Sub

Can't figure where I am going wrong???

Regards
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Code not working

On Wednesday, August 8, 2012 5:05:26 PM UTC-5, Howard wrote:
Here is the code I am having trouble with. It returns all "X"'s in the offset ranges, whereas there should be three "O"'s and one "", (blank).



Whe

J = range A9 and A9 value is "B"

RangerTest is a named range A1 to O1 of sheet1

RangerTest has these values: ABCDEBFGHIJBKL and O1 is blank



When I run the code the offset values a XXXXXXXXXXXXXX and the last offset

O1 is blank. The desired out come should be: XOXXXOXXXXXOXX (with the last offset blank in this example.



Sub Testx()

Dim J As String

Dim RangerTest As Range, Cell As Range

J = Range("A9").Value



For Each Cell In Range("RangerTest")

If Cell.Value = J Then Cell.Offset(5, 0).Value = "O"

If Cell.Value < J Then Cell.Offset(5, 0).Value = "X"

If Cell.Value = "" Then Cell.Offset(5, 0).Value = ""

Next



End Sub



Can't figure where I am going wrong???



Regards

Howard


Send file to dguillett @gmail.com with this msg and I'll look.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Code not working

On Wednesday, August 8, 2012 5:05:26 PM UTC-5, Howard wrote:
Here is the code I am having trouble with. It returns all "X"'s in the offset ranges, whereas there should be three "O"'s and one "", (blank).



Whe

J = range A9 and A9 value is "B"

RangerTest is a named range A1 to O1 of sheet1

RangerTest has these values: ABCDEBFGHIJBKL and O1 is blank



When I run the code the offset values a XXXXXXXXXXXXXX and the last offset

O1 is blank. The desired out come should be: XOXXXOXXXXXOXX (with the last offset blank in this example.



Sub Testx()

Dim J As String

Dim RangerTest As Range, Cell As Range

J = Range("A9").Value



For Each Cell In Range("RangerTest")

If Cell.Value = J Then Cell.Offset(5, 0).Value = "O"

If Cell.Value < J Then Cell.Offset(5, 0).Value = "X"

If Cell.Value = "" Then Cell.Offset(5, 0).Value = ""

Next



End Sub



Can't figure where I am going wrong???



Regards

Howard


I think OP forgot to input a value in cell j (a10)
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Code not working

On Wednesday, August 8, 2012 5:05:26 PM UTC-5, Howard wrote:
Here is the code I am having trouble with. It returns all "X"'s in the offset ranges, whereas there should be three "O"'s and one "", (blank).



Whe

J = range A9 and A9 value is "B"

RangerTest is a named range A1 to O1 of sheet1

RangerTest has these values: ABCDEBFGHIJBKL and O1 is blank



When I run the code the offset values a XXXXXXXXXXXXXX and the last offset

O1 is blank. The desired out come should be: XOXXXOXXXXXOXX (with the last offset blank in this example.



Sub Testx()

Dim J As String

Dim RangerTest As Range, Cell As Range

J = Range("A9").Value



For Each Cell In Range("RangerTest")

If Cell.Value = J Then Cell.Offset(5, 0).Value = "O"

If Cell.Value < J Then Cell.Offset(5, 0).Value = "X"

If Cell.Value = "" Then Cell.Offset(5, 0).Value = ""

Next



End Sub



Can't figure where I am going wrong???



Regards

Howard


Option Explicit
Option Compare Text
Sub TheTestSas()
Dim J As String
Dim RANGERTEST As Range
Dim C As Range
Application.ScreenUpdating = False
J = Range("A10").Value
Range("RANGERTEST").Offset(8).Value = ""
For Each C In Range("RANGERTEST")
If Len(Application.Trim(C)) 0 Then
Select Case C
Case Is = J: C.Offset(8) = "O"
Case Is < J: C.Offset(8) = "X"
End Select
End If
Next
Application.ScreenUpdating = True
End Sub
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
Code not working Maxi[_2_] Excel Programming 3 January 23rd 07 01:37 PM
Code not working NickHK Excel Programming 6 January 17th 07 04:34 AM
Code not working NOW ? But it was before??? Corey Excel Programming 2 August 18th 06 03:30 AM
Pop up code not working Ian Manning Excel Programming 3 April 3rd 06 05:48 PM
VB code is not working like it should Bob Reynolds[_3_] Excel Programming 8 July 19th 04 12:02 AM


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