Solved

Flagging excel cells in VBA

Posted on 2002-05-10
8
287 Views
Last Modified: 2010-05-02
I am writing an application in VBA to do simple subtotaling, completely independent of the subtotaling functions in excel.
I need a way to mark cells by manipulating a hidden property of some sort, so that the app sees these cells as subtotal cells.  The marking needs to occur through the code, and needs to be invisible to the user.  I can do it by bolding the text for example, but that is not elegant since a user could modify it.  Any ideas?
0
Comment
Question by:lmindlin
  • 4
  • 3
8 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
ID: 7002293
could you use names?
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7002327
Hi lmindlin,

Going on the way Richie mentioned

-Choose insert | name | define
-then with CTRL+mouseclick select the cells you want to use in teh range
-call it SubTotal

-now in code you can do something like this to loop through the values

Sub t()
Dim c
  For Each c In ActiveWorkbook.Names("SubTotal").RefersToRange.Cells
    MsgBox c.Value
  Next
End Sub

:O)Bruintje
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7002353
<offtopic>
Hi bruintje! where are you when we need you?
could you see this:
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=msoffice&qid=20299301
</offtopic>
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7002368
<OT>i tried something and bk has repeated that in his recap :) i'm EE tired, programming tired and maybe i need a few days off on the beach whenever summer in the Netherlands is kind enough to make that happen<OT>
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7002440
Rest, rest... who needs a keyboard to live anyway?
:)
0
 
LVL 12

Expert Comment

by:roverm
ID: 7002452
<continue offtopic>
Brian:
Well, we should get nice weather Saturday and Sunday so...enjoy life! Then we can get some points as well ;-)
</continue offtopic>

lmindlin:

Yes, I would use the named ranges as well.
However, if you don't like using that, how about creating a "shadow" sheet, hidden for the user (Sheet.Visible = xlVeryHidden) ?
Then use the SelectionChange event to capture the contents of a cell and copy it, along with your properties to the hidden sheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Debug.Print Target.Address(, , xlR1C1)
    'build copy code here
End Sub

D'Mzzl!
RoverM
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7002479
<My last OT response here> Mark > weather better be nice since i got to do some work on my new bicycle away from a keyboard.....points enough for everyone these days ;) more then 80000 on Open Q's in Office alone</OT>
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7002748
Thanks for "A" grade but i think bruintje has explained the point better than me.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now