Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Displaying Cell Value in UserForm Label

I have created an Excel Add-In that formerly displayed the add-in's version
and date in a message box based on values in one of the add-ins worksheets
using the following (where A1 contained the version number and A2 contained
the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure out how
to get data from a worksheet into a string of text in a label within the
UserForm. Can someone point me to an example?

Thank you,

Frank Hayes


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Displaying Cell Value in UserForm Label

Hi
Not tested but...
If you have a Label on the form called Label1 then in the
Userform_Initialize sub (double click the form while editing and scroll
to this event) write

Label1.Caption = "Version "&
ThisWorkBook.Worksheets("Sheet1").Range("A1")& _
" updated on "&ThisWorkBook.Worksheets("Sheet1").Range("A2" )

I put in the ThisWorkBook bit as it would use the Active workbook
otherwise.

regards
Paul

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Displaying Cell Value in UserForm Label

Hi Frank,

Try:

Private Sub UserForm_Initialize()
With Worksheets("Sheet1")
Label1.Caption = "Version " & .Range("A1") & _
" updated on " & .Range("A2")
End With
End Sub


---
Regards,
Norman



"Frank & Pam Hayes" wrote in message
news:oE51f.13366$Vt3.12370@trnddc01...
I have created an Excel Add-In that formerly displayed the add-in's version
and date in a message box based on values in one of the add-ins worksheets
using the following (where A1 contained the version number and A2 contained
the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure out
how to get data from a worksheet into a string of text in a label within
the UserForm. Can someone point me to an example?

Thank you,

Frank Hayes




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Displaying Cell Value in UserForm Label

Thank you both for the solutions. I really appreciate it.

Frank


"Frank & Pam Hayes" wrote in message
news:oE51f.13366$Vt3.12370@trnddc01...
I have created an Excel Add-In that formerly displayed the add-in's version
and date in a message box based on values in one of the add-ins worksheets
using the following (where A1 contained the version number and A2 contained
the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure out
how to get data from a worksheet into a string of text in a label within
the UserForm. Can someone point me to an example?

Thank you,

Frank Hayes




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Displaying Cell Value in UserForm Label

This solution works fine in a regular workbook, but when I save it as an XLA
add-in file I get an error of the Worksheets Object. Any ideas?

Frank



"Frank & Pam Hayes" wrote in message
news:oE51f.13366$Vt3.12370@trnddc01...
I have created an Excel Add-In that formerly displayed the add-in's version
and date in a message box based on values in one of the add-ins worksheets
using the following (where A1 contained the version number and A2 contained
the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure out
how to get data from a worksheet into a string of text in a label within
the UserForm. Can someone point me to an example?

Thank you,

Frank Hayes






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Displaying Cell Value in UserForm Label

Hi Frank,

What code are you using to display the userform and where is that code
placed?

What line of code is highlighted when your error occurs?

---
Regards,
Norman

"Frank & Pam Hayes" wrote in message
news:V7i1f.10254$Ll2.5073@trnddc04...
This solution works fine in a regular workbook, but when I save it as an
XLA add-in file I get an error of the Worksheets Object. Any ideas?

Frank



"Frank & Pam Hayes" wrote in message
news:oE51f.13366$Vt3.12370@trnddc01...
I have created an Excel Add-In that formerly displayed the add-in's
version and date in a message box based on values in one of the add-ins
worksheets using the following (where A1 contained the version number and
A2 contained the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure out
how to get data from a worksheet into a string of text in a label within
the UserForm. Can someone point me to an example?

Thank you,

Frank Hayes






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Displaying Cell Value in UserForm Label

Norman,

My form name is AboutThis. I am calling it with the following subroutine:

Sub AboutThisForm()
AboutThis.Show
Unload About.This
End Sub

This code is placed in a module of the XLA file and is called via a custom
toolbar button that executes the AboutThisForm macro.

When the error occurs, the AboutThis.Show line is highlighted.

The exact error reads: Run Time Error '9': Subscript out of range.

Thanks,

Frank


"Norman Jones" wrote in message
...
Hi Frank,

What code are you using to display the userform and where is that code
placed?

What line of code is highlighted when your error occurs?

---
Regards,
Norman

"Frank & Pam Hayes" wrote in message
news:V7i1f.10254$Ll2.5073@trnddc04...
This solution works fine in a regular workbook, but when I save it as an
XLA add-in file I get an error of the Worksheets Object. Any ideas?

Frank



"Frank & Pam Hayes" wrote in message
news:oE51f.13366$Vt3.12370@trnddc01...
I have created an Excel Add-In that formerly displayed the add-in's
version and date in a message box based on values in one of the add-ins
worksheets using the following (where A1 contained the version number and
A2 contained the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure out
how to get data from a worksheet into a string of text in a label within
the UserForm. Can someone point me to an example?

Thank you,

Frank Hayes








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Displaying Cell Value in UserForm Label

Hi Frank,

I regret to say that I have been unable to reproduce your problem.

To replicate the relevant elements of your scenario, I created an addin with
a useform. I added the previously suggested UserForm_Initialize code. In a
standard module, I added your AboutThisForm code. I attached a toolbar to
the addin and assigned the AboutThisForm macro to a toolbar button.

The code ran without problem when invoked by the button.

Two inccidental points:

I assume that the dot in
Unload About.This

is a typo.


In the form's initialize code, I changed

With Worksheets("Sheet1")

to
With Thisworkbook.Sheets("Sheet1")

---
Regards,
Norman



"Frank & Pam Hayes" wrote in message
news:h4j1f.6071$Tz2.1232@trnddc02...
Norman,

My form name is AboutThis. I am calling it with the following
subroutine:

Sub AboutThisForm()
AboutThis.Show
Unload About.This
End Sub

This code is placed in a module of the XLA file and is called via a custom
toolbar button that executes the AboutThisForm macro.

When the error occurs, the AboutThis.Show line is highlighted.

The exact error reads: Run Time Error '9': Subscript out of range.

Thanks,

Frank


"Norman Jones" wrote in message
...
Hi Frank,

What code are you using to display the userform and where is that code
placed?

What line of code is highlighted when your error occurs?

---
Regards,
Norman

"Frank & Pam Hayes" wrote in message
news:V7i1f.10254$Ll2.5073@trnddc04...
This solution works fine in a regular workbook, but when I save it as an
XLA add-in file I get an error of the Worksheets Object. Any ideas?

Frank



"Frank & Pam Hayes" wrote in message
news:oE51f.13366$Vt3.12370@trnddc01...
I have created an Excel Add-In that formerly displayed the add-in's
version and date in a message box based on values in one of the add-ins
worksheets using the following (where A1 contained the version number
and A2 contained the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure out
how to get data from a worksheet into a string of text in a label
within the UserForm. Can someone point me to an example?

Thank you,

Frank Hayes










  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Displaying Cell Value in UserForm Label

Norman ... you fixed my problem! Changing

With Worksheets("Sheet1")
to
With Thisworkbook.Sheets("Sheet1")

corrected the error I was getting. I think it is going to be a long time
until I have mastered the nuances of VBA.

I truely appreciate all the time and effort you put into troubleshooting my
code. Thank you.

Frank

"Norman Jones" wrote in message
...
Hi Frank,

I regret to say that I have been unable to reproduce your problem.

To replicate the relevant elements of your scenario, I created an addin
with a useform. I added the previously suggested UserForm_Initialize code.
In a standard module, I added your AboutThisForm code. I attached a
toolbar to the addin and assigned the AboutThisForm macro to a toolbar
button.

The code ran without problem when invoked by the button.

Two inccidental points:

I assume that the dot in
Unload About.This

is a typo.


In the form's initialize code, I changed

With Worksheets("Sheet1")

to
With Thisworkbook.Sheets("Sheet1")

---
Regards,
Norman



"Frank & Pam Hayes" wrote in message
news:h4j1f.6071$Tz2.1232@trnddc02...
Norman,

My form name is AboutThis. I am calling it with the following
subroutine:

Sub AboutThisForm()
AboutThis.Show
Unload About.This
End Sub

This code is placed in a module of the XLA file and is called via a
custom toolbar button that executes the AboutThisForm macro.

When the error occurs, the AboutThis.Show line is highlighted.

The exact error reads: Run Time Error '9': Subscript out of range.

Thanks,

Frank


"Norman Jones" wrote in message
...
Hi Frank,

What code are you using to display the userform and where is that code
placed?

What line of code is highlighted when your error occurs?

---
Regards,
Norman

"Frank & Pam Hayes" wrote in message
news:V7i1f.10254$Ll2.5073@trnddc04...
This solution works fine in a regular workbook, but when I save it as
an XLA add-in file I get an error of the Worksheets Object. Any
ideas?

Frank



"Frank & Pam Hayes" wrote in message
news:oE51f.13366$Vt3.12370@trnddc01...
I have created an Excel Add-In that formerly displayed the add-in's
version and date in a message box based on values in one of the add-ins
worksheets using the following (where A1 contained the version number
and A2 contained the date last updated):

Sub DisplayVersion

Msgbox "Version "&Worksheets("Sheet1").Range("A1")& _
" updated on "&Worksheets("Sheet1").Range("A2")

End Sub

I am trying to move this function to a UserForm but can not figure
out how to get data from a worksheet into a string of text in a label
within the UserForm. Can someone point me to an example?

Thank you,

Frank Hayes












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
Userform with textbox displaying Cell B1 Value JMay Excel Discussion (Misc queries) 2 October 4th 09 12:56 AM
Userform Label Steve[_9_] Excel Discussion (Misc queries) 7 October 29th 07 09:51 PM
Displaying cell values in a Userform michaelberrier Excel Discussion (Misc queries) 3 June 8th 06 05:24 PM
Userform Label question David Goodall Excel Programming 2 October 29th 04 03:33 PM
Userform blinking label Ed Excel Programming 2 July 17th 04 12:24 AM


All times are GMT +1. The time now is 02:16 AM.

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"