Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Summing Cells and Formatting

1.) How do I change the TextBox21 line of code to make it
sum the cells A4, A9, E4, AND E9?

Private Sub CommandButton1_click()
With UserForm2
.TextBox21.Value = Application.Sum(Cells
("A4", "A9", "E4", "E9"))
.Show
End With
End Sub

2.) For TextBox21, what would the code be to:
a. make the value percentage, and
b. make the font bold/red when the value is not 100%?

Thanks, Phil

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Summing Cells and Formatting

Phil,

I think this does it all for you

Private Sub CommandButton1_click()
Dim rng As Range
Dim nValue As Double

Set rng = Range("A4, A9, E4, E9")
nValue = Application.Sum(rng)
With UserForm2
With .TextBox21
.Value = Format(nValue, "0%")
If nValue = 1 Then
.Font.Bold = True
.ForeColor = RGB(&HFF, &H0, &H0)
Else
.Font.Bold = False
.ForeColor = RGB(&H0, &H0, &H0)
End If
End With
.Show
End With
End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Phil Hageman" wrote in message
...
1.) How do I change the TextBox21 line of code to make it
sum the cells A4, A9, E4, AND E9?

Private Sub CommandButton1_click()
With UserForm2
.TextBox21.Value = Application.Sum(Cells
("A4", "A9", "E4", "E9"))
.Show
End With
End Sub

2.) For TextBox21, what would the code be to:
a. make the value percentage, and
b. make the font bold/red when the value is not 100%?

Thanks, Phil



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
Summing 2 columns cells into a 3rd colums cells Wayne Cadigan Excel Discussion (Misc queries) 1 May 13th 10 08:34 PM
not summing all the cells Alina Roumania Excel Discussion (Misc queries) 2 April 13th 10 09:41 AM
Summing Cells with #N/A Joan NYC Excel Worksheet Functions 8 February 26th 07 07:57 AM
Summing of Two cells does not sum!! Joe D Excel Discussion (Misc queries) 2 July 17th 05 10:53 PM
Finding cells and summing variable cells Chris M.[_3_] Excel Programming 3 August 21st 03 09:13 PM


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