Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default another won't work for you fine people

here is the code.

Sub TOTHERIGHT()
Dim B As Double
Dim T As Double

Range("E3:E6").Select
CaseText = activecell.Value
Select Case (CaseText)
Case Is < "TOTAL ACCOUNTS"
activecell.Offset(0, 1).Select
B = activecell.Value
T = T + B
End Select

MsgBox (T)
End Sub

E3:E6 contains text
F3:F6 contains numbers

I want a message box that contains the sum of all the numbers to th
right of cells that don't say "TOTAL ACCOUNTS"

When I run this I get a message box that says

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default another won't work for you fine people

ksknapp


Try

Sub TOTHERIGHT()
Dim r As Range
Dim j As Integer
Dim T As Double
Dim WorkRange As Range
Set WorkRange = ActiveSheet.Range("E3:E6")
For r = 1 To WorkRange.Rows.Count
If WorkRange.Cells(r, 1) < "TOTAL ACCOUNTS" Then
T = WorkRange.Cells(r, 1).offset(0,1).Value + T
End If
Next r
MsgBox (T)
End Su

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default another won't work for you fine people

You need to use a loop to iterate through the cells.
Try something like:

Sub TOTHERIGHT()
Dim T As Double
Dim myCell as range
Dim myRange as range

Set myRange = Range("E3:E6")
T = 0
For each myCell in myRange
CaseText = myCell.Value
Select Case (CaseText)
Case Is < "TOTAL ACCOUNTS"
T = T + MyCell.Offset(0, 1).value
End Select

MsgBox (T)
End Sub

--
Darren
"ksnapp " wrote in message
...
here is the code.

Sub TOTHERIGHT()
Dim B As Double
Dim T As Double

Range("E3:E6").Select
CaseText = activecell.Value
Select Case (CaseText)
Case Is < "TOTAL ACCOUNTS"
activecell.Offset(0, 1).Select
B = activecell.Value
T = T + B
End Select

MsgBox (T)
End Sub

E3:E6 contains text
F3:F6 contains numbers

I want a message box that contains the sum of all the numbers to the
right of cells that don't say "TOTAL ACCOUNTS"

When I run this I get a message box that says 0


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default another won't work for you fine people

Oops forgot to close the loop - see amended code below:
Darren
----- Original Message -----
From: "Darren Hill"
Newsgroups: microsoft.public.excel.programming
Sent: Thursday, March 04, 2004 5:13 AM
Subject: another won't work for you fine people


You need to use a loop to iterate through the cells.
Try something like:

Sub TOTHERIGHT()
Dim T As Double
Dim myCell as range
Dim myRange as range

Set myRange = Range("E3:E6")
T = 0
For each myCell in myRange
CaseText = myCell.Value
Select Case (CaseText)
Case Is < "TOTAL ACCOUNTS"
T = T + MyCell.Offset(0, 1).value
End Select

' close the loop, you silly boy.
Next myCell

MsgBox (T)
End Sub

--
Darren
"ksnapp " wrote in message
...
here is the code.

Sub TOTHERIGHT()
Dim B As Double
Dim T As Double

Range("E3:E6").Select
CaseText = activecell.Value
Select Case (CaseText)
Case Is < "TOTAL ACCOUNTS"
activecell.Offset(0, 1).Select
B = activecell.Value
T = T + B
End Select

MsgBox (T)
End Sub

E3:E6 contains text
F3:F6 contains numbers

I want a message box that contains the sum of all the numbers to the
right of cells that don't say "TOTAL ACCOUNTS"

When I run this I get a message box that says 0


---
Message posted from http://www.ExcelForum.com/





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default another won't work for you fine people

Sub test3001()
Range("A10").Formula = _
"=SUMPRODUCT((E3:E6=""TOTAL ACCOUNTS"")*(F3:F6))"
MsgBox Range("A10").Value
End Sub

Alan Beban

ksnapp < wrote:
here is the code.

Sub TOTHERIGHT()
Dim B As Double
Dim T As Double

Range("E3:E6").Select
CaseText = activecell.Value
Select Case (CaseText)
Case Is < "TOTAL ACCOUNTS"
activecell.Offset(0, 1).Select
B = activecell.Value
T = T + B
End Select

MsgBox (T)
End Sub

E3:E6 contains text
F3:F6 contains numbers

I want a message box that contains the sum of all the numbers to the
right of cells that don't say "TOTAL ACCOUNTS"

When I run this I get a message box that says 0


---
Message posted from http://www.ExcelForum.com/




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
Checkboxes Don't Work For Other People Thomas M. Excel Discussion (Misc queries) 2 June 9th 09 11:21 PM
I want to set up a monthly work roster for 4 or 5 people Laney Excel Worksheet Functions 2 December 15th 08 12:36 AM
can two people work on the same worksheet from different computer Marci Excel Discussion (Misc queries) 2 October 30th 08 04:43 PM
Macro fine Run fine from Select but not from KB Shortcut? [email protected] Excel Discussion (Misc queries) 8 August 31st 06 02:06 AM
monthly work schedule for 2 people on same calendar roadbitch Excel Discussion (Misc queries) 0 May 18th 06 01:17 PM


All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"