Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA for a complex If...Then Loop

I know it can be done, but I just don't know the syntax.

I want to tell Excel, to check if a range of cells in the a row as a
particular formating, and for each cell with that formatting to make the some
of the numbers in those cell.

I started the programming, but I just don't know how to write the "Then"
part (in cell E15, make the some of all the cell with the matching formating)

Sub test1()
If Feuil59.Range("U15", "AT15").Interior.ColorIndex = 50 Then
E15 = Sum(U15, AT15) ?????
End If
End Sub

Hope I'm clear enough and thanks for your help

Sophie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default VBA for a complex If...Then Loop

Hi,

I think you may mean this

Sub test1()
Dim MyRange As Range
Set MyRange = Range("U15:AT15")
For Each c In MyRange
If c.Interior.ColorIndex = 50 Then
mytotal = mytotal + c
End If
Next
Range("E15") = mytotal
End Sub


Mike

"Fluffy" wrote:

I know it can be done, but I just don't know the syntax.

I want to tell Excel, to check if a range of cells in the a row as a
particular formating, and for each cell with that formatting to make the some
of the numbers in those cell.

I started the programming, but I just don't know how to write the "Then"
part (in cell E15, make the some of all the cell with the matching formating)

Sub test1()
If Feuil59.Range("U15", "AT15").Interior.ColorIndex = 50 Then
E15 = Sum(U15, AT15) ?????
End If
End Sub

Hope I'm clear enough and thanks for your help

Sophie

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA for a complex If...Then Loop

Hello Mike,

It is working fine :-)

Thank you very much for your help.

Sophie


"Mike H" wrote:

Hi,

I think you may mean this

Sub test1()
Dim MyRange As Range
Set MyRange = Range("U15:AT15")
For Each c In MyRange
If c.Interior.ColorIndex = 50 Then
mytotal = mytotal + c
End If
Next
Range("E15") = mytotal
End Sub


Mike

"Fluffy" wrote:

I know it can be done, but I just don't know the syntax.

I want to tell Excel, to check if a range of cells in the a row as a
particular formating, and for each cell with that formatting to make the some
of the numbers in those cell.

I started the programming, but I just don't know how to write the "Then"
part (in cell E15, make the some of all the cell with the matching formating)

Sub test1()
If Feuil59.Range("U15", "AT15").Interior.ColorIndex = 50 Then
E15 = Sum(U15, AT15) ?????
End If
End Sub

Hope I'm clear enough and thanks for your help

Sophie

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default VBA for a complex If...Then Loop

Your welcome

"Fluffy" wrote:

Hello Mike,

It is working fine :-)

Thank you very much for your help.

Sophie


"Mike H" wrote:

Hi,

I think you may mean this

Sub test1()
Dim MyRange As Range
Set MyRange = Range("U15:AT15")
For Each c In MyRange
If c.Interior.ColorIndex = 50 Then
mytotal = mytotal + c
End If
Next
Range("E15") = mytotal
End Sub


Mike

"Fluffy" wrote:

I know it can be done, but I just don't know the syntax.

I want to tell Excel, to check if a range of cells in the a row as a
particular formating, and for each cell with that formatting to make the some
of the numbers in those cell.

I started the programming, but I just don't know how to write the "Then"
part (in cell E15, make the some of all the cell with the matching formating)

Sub test1()
If Feuil59.Range("U15", "AT15").Interior.ColorIndex = 50 Then
E15 = Sum(U15, AT15) ?????
End If
End Sub

Hope I'm clear enough and thanks for your help

Sophie

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
complex color fill conditions- if statements or complex formula? lilly8008 Excel Discussion (Misc queries) 1 December 18th 09 04:57 AM
Very complex Loop LuisE Excel Programming 4 August 23rd 08 01:55 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
Loop for a Complex Formula monir Excel Programming 3 March 26th 05 07:37 PM
Do---Loop Error in Complex Code Pete T[_2_] Excel Programming 5 October 14th 03 06:54 PM


All times are GMT +1. The time now is 07:09 PM.

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"