Solved

Flagging excel cells in VBA

Posted on 2002-05-10
8
288 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 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

9 Experts available now in Live!

Get 1:1 Help Now