PC Review


Reply
Thread Tools Rate Thread

Can userforms be embedded in a spreadsheet cell?

 
 
tbd
Guest
Posts: n/a
 
      9th Oct 2009
Greetings!
I'm just exploring ways to encapsulate information on a spreadsheet.
If there's a way, I'd be interested even if it doesn't involve a userform.

Thanks/Cheers!
 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      9th Oct 2009
build your own oblects using class modules. depends on what it is that you
want to do of course


"tbd" wrote:

> Greetings!
> I'm just exploring ways to encapsulate information on a spreadsheet.
> If there's a way, I'd be interested even if it doesn't involve a userform.
>
> Thanks/Cheers!

 
Reply With Quote
 
tbd
Guest
Posts: n/a
 
      9th Oct 2009
Hi Patrick,
I like the sound of this... Tried exporting a Class object to .cls
file, and inserted it using \insert\object\fromfile. A floating icon with
filename shows-up (it's not embedded in cell, maybe OK), but I'd like to see
some sort of GUI - like a userform. VBA would need to position about 30 of
these, then user edits inside each one...

Maybe it's time to switch to VB, and embed Excel objects in a VB GUI.

Thanks/Cheers!

"Patrick Molloy" wrote:

> build your own oblects using class modules. depends on what it is that you
> want to do of course
>
>
> "tbd" wrote:
>
> > Greetings!
> > I'm just exploring ways to encapsulate information on a spreadsheet.
> > If there's a way, I'd be interested even if it doesn't involve a userform.
> >
> > Thanks/Cheers!

 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      12th Oct 2009
here's a very simple example - you sound knowledgable enough ....but let me
know
there are three parts:
(1) so in a standard module put this code:
Option Explicit
Public col As Collection
Public Function GetCellClass(targetaddr As String) As cellstuff
On Error Resume Next
If col Is Nothing Then
Set col = New Collection
Else
Set GetCellClass = col.Item(targetaddr)
End If
If GetCellClass Is Nothing Then
Set GetCellClass = New cellstuff
col.Add GetCellClass, targetaddr
End If
End Function

(2)in a CLASS module, named cellstuff, put this code
Option Explicit

Public PrevValue As String
Public Comment As String
Public User As String
Public CurrentValue As String

(3)and finally, in a sheet's code page, this:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim celldata As cellstuff
Set celldata = GetCellClass(Target.Address(False, False))
With celldata
.PrevValue = .CurrentValue
.CurrentValue = Target.Value
.User = "me2"
End With
End Sub




so how does it work
When you enter a value into a cell, the chanmge event fires, this gets a
cellstuff object
it copies the current value in cellstuff to teh Privious value. pretty
simple hey? but there's no way to do this built in !
Anyway, the getcellstuff function checks to see if the collection of objects
exists. If it doesn't, create it. The it recalls the appropriate object - i
use the cell address as the key, as it be unique to any cell (or excel would
break).
if the object doesn't exist, its created, then the celldata object is handed
back to the call in the change event.

it should be pretty easy to push teh data into a userform abd vice-versa...I
just wanted to give you the idea

Hit YES if this helps

cheers
Patrick














"tbd" wrote:

> Hi Patrick,
> I like the sound of this... Tried exporting a Class object to .cls
> file, and inserted it using \insert\object\fromfile. A floating icon with
> filename shows-up (it's not embedded in cell, maybe OK), but I'd like to see
> some sort of GUI - like a userform. VBA would need to position about 30 of
> these, then user edits inside each one...
>
> Maybe it's time to switch to VB, and embed Excel objects in a VB GUI.
>
> Thanks/Cheers!
>
> "Patrick Molloy" wrote:
>
> > build your own oblects using class modules. depends on what it is that you
> > want to do of course
> >
> >
> > "tbd" wrote:
> >
> > > Greetings!
> > > I'm just exploring ways to encapsulate information on a spreadsheet.
> > > If there's a way, I'd be interested even if it doesn't involve a userform.
> > >
> > > Thanks/Cheers!

 
Reply With Quote
 
tbd
Guest
Posts: n/a
 
      15th Oct 2009
Patrick, THANKS!!!
Really appreciate the example code! Probably never would have implemented
this on my own, but I can see the value of having this tool, AWESOME! - will
keep it in a safe place.

BTW, sorry for slow reply, something at MS changed(?) in the hyperlink chain
I used to use to get here - it took a while to google a known post, and
re-link.
--
The Cobra
[Footnote:] A few Cobras in your home will soon clear it of Rats and Mice.
Of course, you will still have the Cobras. (Will Cuppy
http://en.wikiquote.org/wiki/Will_Cuppy)


"Patrick Molloy" wrote:

> here's a very simple example - you sound knowledgable enough ....but let me
> know
> there are three parts:
> (1) so in a standard module put this code:
> Option Explicit
> Public col As Collection
> Public Function GetCellClass(targetaddr As String) As cellstuff
> On Error Resume Next
> If col Is Nothing Then
> Set col = New Collection
> Else
> Set GetCellClass = col.Item(targetaddr)
> End If
> If GetCellClass Is Nothing Then
> Set GetCellClass = New cellstuff
> col.Add GetCellClass, targetaddr
> End If
> End Function
>
> (2)in a CLASS module, named cellstuff, put this code
> Option Explicit
>
> Public PrevValue As String
> Public Comment As String
> Public User As String
> Public CurrentValue As String
>
> (3)and finally, in a sheet's code page, this:
> Option Explicit
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim celldata As cellstuff
> Set celldata = GetCellClass(Target.Address(False, False))
> With celldata
> .PrevValue = .CurrentValue
> .CurrentValue = Target.Value
> .User = "me2"
> End With
> End Sub
>
>
>
>
> so how does it work
> When you enter a value into a cell, the chanmge event fires, this gets a
> cellstuff object
> it copies the current value in cellstuff to teh Privious value. pretty
> simple hey? but there's no way to do this built in !
> Anyway, the getcellstuff function checks to see if the collection of objects
> exists. If it doesn't, create it. The it recalls the appropriate object - i
> use the cell address as the key, as it be unique to any cell (or excel would
> break).
> if the object doesn't exist, its created, then the celldata object is handed
> back to the call in the change event.
>
> it should be pretty easy to push teh data into a userform abd vice-versa...I
> just wanted to give you the idea
>
> Hit YES if this helps
>
> cheers
> Patrick
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> "tbd" wrote:
>
> > Hi Patrick,
> > I like the sound of this... Tried exporting a Class object to .cls
> > file, and inserted it using \insert\object\fromfile. A floating icon with
> > filename shows-up (it's not embedded in cell, maybe OK), but I'd like to see
> > some sort of GUI - like a userform. VBA would need to position about 30 of
> > these, then user edits inside each one...
> >
> > Maybe it's time to switch to VB, and embed Excel objects in a VB GUI.
> >
> > Thanks/Cheers!
> >
> > "Patrick Molloy" wrote:
> >
> > > build your own oblects using class modules. depends on what it is that you
> > > want to do of course
> > >
> > >
> > > "tbd" wrote:
> > >
> > > > Greetings!
> > > > I'm just exploring ways to encapsulate information on a spreadsheet.
> > > > If there's a way, I'd be interested even if it doesn't involve a userform.
> > > >
> > > > Thanks/Cheers!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New to Userforms - need return value in a cell Brad E. Microsoft Excel Programming 0 4th Mar 2010 03:25 PM
Reference to Embedded Spreadsheet within a Spreadsheet bluegrassstateworker Microsoft Excel Discussion 3 1st Feb 2008 08:12 PM
How to read Excel spreadsheet embedded in another spreadsheet GH Microsoft VB .NET 3 6th Feb 2007 04:41 PM
Updating entries on a spreadsheet via Userforms rayzgurl Microsoft Excel Programming 4 4th Feb 2004 01:17 PM
Hiding Cell Formulas that are linked to Userforms =?Utf-8?B?Unlhbg==?= Microsoft Excel Misc 1 13th Jan 2004 03:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:26 PM.