PC Review


Reply
Thread Tools Rate Thread

Displaying data in user form from active worksheet

 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      16th Oct 2006
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Oct 2006
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

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Oct 2006
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 With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Oct 2006
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 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
Displaying data in a VBA User Form cardfan3206 Microsoft Excel Programming 1 22nd Oct 2009 09:48 PM
displaying input data on user form as currency mantrid Microsoft Excel Discussion 2 28th Apr 2007 01:56 AM
displaying input data on user form as currency mantrid Microsoft Excel Programming 2 28th Apr 2007 01:56 AM
Excel not displaying the last active worksheet when opened =?Utf-8?B?R2VtaW5pc3Q=?= Microsoft Excel Misc 0 22nd Nov 2006 02:31 PM
displaying the user form data cyzax7 via OfficeKB.com Microsoft Excel Programming 3 12th Jun 2006 01:49 AM


Features
 

Advertising
 

Newsgroups
 


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