Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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"???


--
Celt
------------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=520343

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default quick code question


How do I say "not equal"???


<


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
Quick Code Nimish Excel Discussion (Misc queries) 3 September 11th 06 07:19 PM
Quick question - quick answer about assigning shortcut keys funkymonkUK[_75_] Excel Programming 1 October 13th 05 10:50 AM
Need Help With Code Quick!! alexm999[_90_] Excel Programming 4 September 18th 04 09:24 AM
quick code question dave!! Excel Programming 2 May 18th 04 04:56 PM
Quick VBA code question (if...then statement) abxy[_31_] Excel Programming 4 February 26th 04 01:04 AM


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