Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default setting a control's text from the value of a cell

Is this possible?

Here's what I'm looking to do. When the excel workbook loads, I want
it to:
1. Load the Userform first
2. set the text values of controls to a particular cell's value (not
all controls to one cell value).

ie. (and this psudo code mixed w/ vb)
<code
Public Class ThisWorkbook

Private Sub ThisWorkbook_Startup(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Startup
lblParagraph.Text=ActiveWorkbook.Sheets("MySheet") .Activate
Range("A1").Select
End Sub

Private Sub ThisWorkbook_Shutdown(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Shutdown

End Sub

End Class
</code
Now, I'm using VS2008. When I begin to type my label control from the
user form into the startup workbook, it doesn't see the label control
in the type ahead. Or does it go in some sort of 'OnUserFormLoad'
procedure and the workbook_startup just loads the form?

I don't know.

Any help would be appreciated. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default setting a control's text from the value of a cell

Although you mention using VS2008, you don't mention which version of Excel
you are using nor is it clear whether you know how to do this within Excel
and just need help with the VS syntax, or whether you are looking for help
with the Excel object model.

I don't have VS2008, so I'll provide a within-Excel solution here to give
you the syntax; hopefully that is what you need and you can adjust it to meet
your specific project requirements.

Private Sub Workbook_Open()
UserForm1.Label1.Caption = Sheet1.Range("A1").Value
UserForm1.Label2.Caption = Sheet1.Range("A2").Value
UserForm1.Show
End Sub

HTH,
Keith


"Nondisclosure007" wrote:

Is this possible?

Here's what I'm looking to do. When the excel workbook loads, I want
it to:
1. Load the Userform first
2. set the text values of controls to a particular cell's value (not
all controls to one cell value).

ie. (and this psudo code mixed w/ vb)
<code
Public Class ThisWorkbook

Private Sub ThisWorkbook_Startup(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Startup
lblParagraph.Text=ActiveWorkbook.Sheets("MySheet") .Activate
Range("A1").Select
End Sub

Private Sub ThisWorkbook_Shutdown(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Shutdown

End Sub

End Class
</code
Now, I'm using VS2008. When I begin to type my label control from the
user form into the startup workbook, it doesn't see the label control
in the type ahead. Or does it go in some sort of 'OnUserFormLoad'
procedure and the workbook_startup just loads the form?

I don't know.

Any help would be appreciated. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default setting a control's text from the value of a cell

I'm sorry about that Ketih, It's Excel 2003.

I was drawing a blank on how to do this in excel.

The whole reason I was using VS2008 was simply, and I know this sounds
lame, was for the type ahead features.

Thank you for below. That will work.

I should probably drop VS2008 and just use the VBA editor w/ Excel
2003 to create the form. I don't think VS2008 is getting me anything,
from functionality in the form perspective, that the VBA editor in
Excel can't.

On Oct 8, 4:37*pm, ker_01 wrote:
Although you mention using VS2008, you don't mention which version of Excel
you are using nor is it clear whether you know how to do this within Excel
and just need help with the VS syntax, or whether you are looking for help
with the Excel object model.

I don't have VS2008, so I'll provide a within-Excel solution here to give
you the syntax; hopefully that is what you need and you can adjust it to meet
your specific project requirements.

Private Sub Workbook_Open()
* *UserForm1.Label1.Caption = Sheet1.Range("A1").Value
* *UserForm1.Label2.Caption = Sheet1.Range("A2").Value
* *UserForm1.Show
End Sub

HTH,
Keith



"Nondisclosure007" wrote:
Is this possible?


Here's what I'm looking to do. *When the excel workbook loads, I want
it to:
1. *Load the Userform first
2. *set the text values of controls to a particular cell's value (not
all controls to one cell value).


ie. (and this psudo code mixed w/ vb)
<code
Public Class ThisWorkbook


* * Private Sub ThisWorkbook_Startup(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Startup
* * * * *lblParagraph.Text=ActiveWorkbook.Sheets("MySheet" )..Activate
* * Range("A1").Select
* * End Sub


* * Private Sub ThisWorkbook_Shutdown(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Shutdown


* * End Sub


End Class
</code
Now, I'm using VS2008. *When I begin to type my label control from the
user form into the startup workbook, it doesn't see the label control
in the type ahead. *Or does it go in some sort of 'OnUserFormLoad'
procedure and the workbook_startup just loads the form?


I don't know.


Any help would be appreciated. *Thanks.- Hide quoted text -


- Show quoted text -


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
VB control's text/caption is ugly - keeps resizing John[_141_] Excel Programming 1 November 13th 08 11:49 PM
Setting the text in a cell to the text of a cell on a different sheet in the same workbook Max C Excel Programming 6 December 28th 06 04:35 PM
Setting the Chart name as the text from a cell. Sareh Excel Programming 2 July 17th 06 07:41 PM
Setting spaces between text in a cell Erik K via OfficeKB.com[_2_] Excel Programming 8 November 4th 05 10:23 AM
Setting text as a background in cell Brian Excel Worksheet Functions 1 December 9th 04 08:12 PM


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