+ Reply to Thread
Results 1 to 3 of 3

quick code question

  1. #1
    Forum Contributor
    Join Date
    02-03-2005
    Location
    Chicago, IL
    Posts
    101

    quick code question

    I am playing around with some code I was given in a previous post, learning what each peice does. I am trying to tweak it a little to meet my needs. I have a quick question. Here is the code I am working with.....

    Sub MacroYellow()
    Dim i As Long
    Dim j As Long
    Dim Lrow As Long
    Dim Lcol As Long

    Range("A1").Select
    Selection.SpecialCells(xlCellTypeLastCell).Select
    Lrow = ActiveCell.Row
    Lcol = ActiveCell.Column
    For i = 6 To Lrow
    For j = 4 To Lcol
    Application.Goto Cells(i, j)
    If ActiveCell.Value = Fix(ActiveCell.Value) Then
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
    Formula1:="=MOD(ActiveCell.Value,1)=0"
    Selection.FormatConditions(1).Interior.ColorIndex = 6
    End If
    Next j
    Next i
    Range("A1").Select
    End Sub

    Basicallly, this macro is searching columns of data starting at cell D6. the columns contain numbers. I want the macro to check if the number contains a decimal and if so, change the conditional formatting so that the cell turns yellow (I am using conditional formatting so that once the decimal is removed the cell will go back to normal). I think the above will work once I change this line (if I am wrong please tell me!!!!)...

    If ActiveCell.Value = Fix(ActiveCell.Value) Then

    How do I say "not equal"???

  2. #2
    Jim F
    Guest

    RE: quick code question

    Ok the function "Fix" returns the "Integer" portion of the value (leaves off
    the decimal). If you are looking to see if the active cell is a decimal then
    you could simply change it to:

    If ActiveCell.Value <> Fix(ActiveCell.Value)


    "Celt" wrote:

    >
    > I am playing around with some code I was given in a previous post,
    > learning what each peice does. I am trying to tweak it a little to
    > meet my needs. I have a quick question. Here is the code I am working
    > with.....
    >
    > Sub MacroYellow()
    > Dim i As Long
    > Dim j As Long
    > Dim Lrow As Long
    > Dim Lcol As Long
    >
    > Range("A1").Select
    > Selection.SpecialCells(xlCellTypeLastCell).Select
    > Lrow = ActiveCell.Row
    > Lcol = ActiveCell.Column
    > For i = 6 To Lrow
    > For j = 4 To Lcol
    > Application.Goto Cells(i, j)
    > If ActiveCell.Value = Fix(ActiveCell.Value) Then
    > Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual,
    > _
    > Formula1:="=MOD(ActiveCell.Value,1)=0"
    > Selection.FormatConditions(1).Interior.ColorIndex = 6
    > End If
    > Next j
    > Next i
    > Range("A1").Select
    > End Sub
    >
    > Basicallly, this macro is searching columns of data starting at cell
    > D6. the columns contain numbers. I want the macro to check if the
    > number contains a decimal and if so, change the conditional formatting
    > so that the cell turns yellow (I am using conditional formatting so
    > that once the decimal is removed the cell will go back to normal). I
    > think the above will work once I change this line (if I am wrong please
    > tell me!!!!)...
    >
    > If ActiveCell.Value = Fix(ActiveCell.Value) Then
    >
    > How do I say "not equal"???
    >
    >
    > --
    > Celt
    > ------------------------------------------------------------------------
    > Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
    > View this thread: http://www.excelforum.com/showthread...hreadid=520343
    >
    >


  3. #3
    Paul W Smith
    Guest

    Re: quick code question


    > How do I say "not equal"???


    <>



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1