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

Hi All,

I am using VBA to get some records from an Oracle db and then sort and
subtotal them. Everything works fine except that I would like one of
the fields which does not drive the subtotals to be displayed next the
field which shows Item Total. Example:

Account Name | Account # | Amount
Overpayment | 12345678 | 23.00
Overpayment | 12345678 | 77.00

If you drive your subtotals off of Account # then when you collapse the
subtotal one level you will see only 12345678 Total and the Account
Name field will be empty. This normally makes sense because the
subtotaled list could potentially have different information in each
Account Name field. But in my case it is always the same for each
subtotal group. Does anyone know how to programatically make it display
when it is collapsed? I guess I could evaluate the cell above it and
take that value but maybe someone knows a better way here?

Thanks
Mike
msilva@ed (dot) umuc (dot) edu



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and subtotals

Works like a charm - Thanks Tom!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and subtotals

Actually only works like a charm if you want the same value across all
subtotals. I will work out how to loop through each subtotal and
display the proper value for that subtotal. Unless someone already has
it done?



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA and subtotals

Perhaps a modification:

Set rng = Range(Cells(2,"A"),Cells(rows.count,"A").End(xlup) (2))
set rng1 = rng.SpecialCells(xlblanks)
rng1.Formula = "=" & rng1(0,1).Address(0,0)
rng.Formula = rng.Value

I that should fix it. Pardon my omission.

--
Regards,
Tom Ogilvy


"rhody" wrote in message
...
Actually only works like a charm if you want the same value across all
subtotals. I will work out how to loop through each subtotal and
display the proper value for that subtotal. Unless someone already has
it done?



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and subtotals

This was a great tip for creating a subrange of just the blank cells in
a range so that a value could be put in there to aid the user when the
subtotals are collapsed to level 2.

Can this same method be used for finding cells in a range which contain
a certain value and then changing the value in the adjacent cell? So
instead of using:

Set rng = Range("E2:E" & EndCell)
Set rng1 = rng.SpecialCells(xlBlanks)

Maybe something like

Set rng = Range("E2:E" & EndCell)
Set rng1 = rng. ??? Where value = "Foo"

Any ideas?

TIA
Mike



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and subtotals

Easiest thing to do is:

For Each c In Range("E2:E" & RowCnt)
If c.Value = "Your Value" Then
c.Offset(0, 1).Value = "New Value"
FindCnt = FindCnt + 1
End If
Next c



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and subtotals

Easiest thing to do is:

For Each c In Range("E2:E" & RowCnt)
If c.Value = "Your Value" Then
c.Offset(0, 1).Value = "New Value"
FindCnt = FindCnt + 1
End If
Next c



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA and subtotals

No it can't - there isn't an option to do a special cells on a particular
value. Look in Excel VBA help on the Find or FindNext methods to see code
for finding a value in a range.

--
Regards,
Tom Ogilvy

"rhody" wrote in message
...
This was a great tip for creating a subrange of just the blank cells in
a range so that a value could be put in there to aid the user when the
subtotals are collapsed to level 2.

Can this same method be used for finding cells in a range which contain
a certain value and then changing the value in the adjacent cell? So
instead of using:

Set rng = Range("E2:E" & EndCell)
Set rng1 = rng.SpecialCells(xlBlanks)

Maybe something like

Set rng = Range("E2:E" & EndCell)
Set rng1 = rng. ??? Where value = "Foo"

Any ideas?

TIA
Mike



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly 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
Subtotals problem: Excel 2003 (not, AFAIK, the nested subtotals bug) AndyCotgreave Excel Discussion (Misc queries) 3 October 24th 07 11:32 AM
Original subtotals should not be within nested subtotals in excel Mirage Excel Worksheet Functions 1 June 6th 07 01:37 AM
Subtotals: Nested subtotals below higher subtotal RobN Excel Discussion (Misc queries) 1 July 20th 06 09:04 PM
How do I copy an outline w/ subtotals & paste just the subtotals av Excel Discussion (Misc queries) 1 June 20th 05 11:35 PM
Problem with nested subtotals, placing secondary subtotals BELOW . Dawn Cameron Excel Discussion (Misc queries) 1 June 3rd 05 10:13 PM


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

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"