Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with looping function

Hi,
Im not really a vba programmer, so i need some help with this one.
I have large excel sheet with customer which I summarize using
subtotal.

I want a function that does the following :
if total then check the total sum for this row, if negative number set
background for the whole
row = yellow.

I got started but then i got stuck :

Sub TrailMyNegativeNumbers()
'
' TrailMyNegativeNumbers Macro
' Macro recorded 15.02.2006 by Mikal Skaaren
'
' Keyboard Shortcut: Ctrl+z
'

Dim c As Range

' Select the range for the first criteria
Range("A2: A22").Select

For Each c In Selection.Cells

MsgBox (c.Value)

' If c.Value="" then TOTAL
If (c.Value = "") Then

' Get a reference to the right
' Column in the selected row
' and see if that number 0
'

' If negative set the background color
' = yellow

c.EntireRow.Select
With Selection.Font
' .ColorIndex = 12
End With

End If
Next


End Sub

Could anybody help me with this function pleease?

BR
Mike

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need help with looping function

Mike,

It would be easier to use conditional formatting to set the colour.

What exactly is your condition that triggers a yellow colour?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Mike" wrote in message
oups.com...
Hi,
Im not really a vba programmer, so i need some help with this one.
I have large excel sheet with customer which I summarize using
subtotal.

I want a function that does the following :
if total then check the total sum for this row, if negative number set
background for the whole
row = yellow.

I got started but then i got stuck :

Sub TrailMyNegativeNumbers()
'
' TrailMyNegativeNumbers Macro
' Macro recorded 15.02.2006 by Mikal Skaaren
'
' Keyboard Shortcut: Ctrl+z
'

Dim c As Range

' Select the range for the first criteria
Range("A2: A22").Select

For Each c In Selection.Cells

MsgBox (c.Value)

' If c.Value="" then TOTAL
If (c.Value = "") Then

' Get a reference to the right
' Column in the selected row
' and see if that number 0
'

' If negative set the background color
' = yellow

c.EntireRow.Select
With Selection.Font
' .ColorIndex = 12
End With

End If
Next


End Sub

Could anybody help me with this function pleease?

BR
Mike



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
Help with looping dok112[_55_] Excel Programming 0 November 1st 05 05:09 PM
Calling macros, looping function? Can this code be written more efficiently? Punsterr Excel Programming 4 October 7th 05 07:16 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Looping Gusset Gadder Excel Programming 2 December 11th 04 09:16 PM
looping to End Nabeel Moeen Excel Programming 2 February 25th 04 10:52 AM


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