Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Displaying data in user form from active worksheet

I have a worksheet selection change event that calls a user form. Within the
user form, I want to display the value that is one column to the left of the
cell that is selected. How would I do that?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Displaying data in user form from active worksheet

Private Sub Userform_Initialize()
if activecell.column < 1 then
Textbox1.Value = activecell.offset(0,-1).value
End if
End sub

If you want it more sophisticated than that, you would have to make a public
variable declared in a general module to hold a reference to target (set in
the selectionchange event) and accessed by the userform in the initialize or
activate event.

--
Regards,
Tom Ogilvy

"Barb Reinhardt" wrote:

I have a worksheet selection change event that calls a user form. Within the
user form, I want to display the value that is one column to the left of the
cell that is selected. How would I do that?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Displaying data in user form from active worksheet

you want one listbox with each month year combination?

With worksheets("Dates")
for each cell in .Range("B2:B32")
for each i = 1 to 12
useform1.listbox1.AddItem format(DateSerial(cell,i,1),"m/yy")
Next
Next
End with

then in you click event for the listbox

Private Sub Listbox1_click()
Dim s as String, iloc as Long, m as String, y as String
s= Listbox1.Value
iloc = Instr(1,s,"/",vbTextcompare)
m = Left(s,iloc-1)
y = "20" & Right(s,len(s)-iloc)
dt = DateSerial(clng(y),clng(m),1)
activecell.Value = dt
activecell.Numberformat = "m/yy"
End Sub

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote:

I have a worksheet selection change event that calls a user form. Within the
user form, I want to display the value that is one column to the left of the
cell that is selected. How would I do that?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Displaying data in user form from active worksheet

Whoops, posted to the wrong question.

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote:

you want one listbox with each month year combination?

With worksheets("Dates")
for each cell in .Range("B2:B32")
for each i = 1 to 12
useform1.listbox1.AddItem format(DateSerial(cell,i,1),"m/yy")
Next
Next
End with

then in you click event for the listbox

Private Sub Listbox1_click()
Dim s as String, iloc as Long, m as String, y as String
s= Listbox1.Value
iloc = Instr(1,s,"/",vbTextcompare)
m = Left(s,iloc-1)
y = "20" & Right(s,len(s)-iloc)
dt = DateSerial(clng(y),clng(m),1)
activecell.Value = dt
activecell.Numberformat = "m/yy"
End Sub

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote:

I have a worksheet selection change event that calls a user form. Within the
user form, I want to display the value that is one column to the left of the
cell that is selected. How would I do that?

Thanks

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
Displaying a User Form Dan N[_2_] Excel Programming 5 June 22nd 06 12:40 PM
displaying the user form data cyzax7 via OfficeKB.com Excel Programming 3 June 12th 06 01:49 AM
Problem displaying a calculation result in a user form AndyRoo Excel Programming 2 November 24th 05 09:45 PM
Active user form gregork Excel Programming 2 March 5th 04 06:46 AM
Displaying part of a sheet on a user form Phillip[_4_] Excel Programming 1 January 15th 04 04:20 AM


All times are GMT +1. The time now is 07:03 PM.

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"