Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Change Word Total and Grand Total

I have a spreadsheet where I have used the subtotal
function to get subtotals and grandtotals based on a
particular code. However, it would be nice if I could
change them to something that makes more sense.

The subtotals are in Column E and the subtotals have codes
like 32000 Total, 33000 Total. In other words each
subtotal has three zeroes and the word Total in common.
Col D has names and I would like the subtotal to say offset
(-1,-1).Value & "Total". That would give me Jim Total or
the Fred Total etc.

Where the word Grand Total comes in at the bottom of the
range, I would like to change it to Points Total.

I would appreciate any help. Thank you.

--Indu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Change Word Total and Grand Total

You can adapt the sample code for the Find Method

Dim c as Range, firstAddress as String
With Worksheets(1).Columns(5)
Set c = .Find("Total", lookin:=xlValues, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if instr(1,c,"Grand",vbTextcompare) then
c.Value = "Point Total"
else
c.Value = c.Offset(-1,-1).Value & " Total"
end if
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
Regards
Tom Ogilvy


"Indu Aronson" wrote in message
...
I have a spreadsheet where I have used the subtotal
function to get subtotals and grandtotals based on a
particular code. However, it would be nice if I could
change them to something that makes more sense.

The subtotals are in Column E and the subtotals have codes
like 32000 Total, 33000 Total. In other words each
subtotal has three zeroes and the word Total in common.
Col D has names and I would like the subtotal to say offset
(-1,-1).Value & "Total". That would give me Jim Total or
the Fred Total etc.

Where the word Grand Total comes in at the bottom of the
range, I would like to change it to Points Total.

I would appreciate any help. Thank you.

--Indu



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Change Word Total and Grand Total

Try this:
Dim DataRng as Range
Set DataRng = Range("E1:E65535")
Dim Cell as Range
For each Cell in DataRng
'The 1 makes sure that Excel starts from the first cell
'Because everything is being lowercased, make sure total
and grandtotal are always lower cased in the instr
statement
If instr(1, lcase(cell.value), "000 total") 0 then
cell.value = cell.offset(-1, -1).value & " Total"
ElseIf InStr(1, LCase(Cell.Value), "grand total") 0
Then
Cell.Value = "Points Total"
end if
Next

-----Original Message-----
I have a spreadsheet where I have used the subtotal
function to get subtotals and grandtotals based on a
particular code. However, it would be nice if I could
change them to something that makes more sense.

The subtotals are in Column E and the subtotals have

codes
like 32000 Total, 33000 Total. In other words each
subtotal has three zeroes and the word Total in common.
Col D has names and I would like the subtotal to say

offset
(-1,-1).Value & "Total". That would give me Jim Total or
the Fred Total etc.

Where the word Grand Total comes in at the bottom of the
range, I would like to change it to Points Total.

I would appreciate any help. Thank you.

--Indu
.

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
Duplicate Running Total Grand Total In Pivot Table Mathew P Bennett[_2_] Excel Discussion (Misc queries) 1 August 17th 08 03:13 AM
Excel 2002 : Any single button to get sub total and grand total ? Mr. Low Excel Discussion (Misc queries) 2 May 22nd 07 08:46 AM
Should grand total equal average of sub total Bonnie Excel Discussion (Misc queries) 5 January 20th 07 08:46 PM
Pivots - Auto calc % Sub total is of grand total VBA Noob Excel Discussion (Misc queries) 3 August 8th 06 08:46 PM
Adding Data Using Multiple Worksheets to Total into a Grand Total Lillie Excel Worksheet Functions 1 April 19th 05 08:34 PM


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