LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Userform questions -- code included!

Hello -

I recently got some help in building the code below (thanks Bernie!),
but have a couple of questions about it ...

1) how do I call it from a Button? I tried changing the name of the
button to match the Sub name and also tried 'Calling' the Sub from the
button, but neither way worked for me ...

2) On Error, the code below should display a short msgbox and then
then Exit when the user clicks "OK" -- instead, the code continues
(and shows an empty userform) upon hitting OK -- why and how do I fix
it?

3) As part of my testing, I changed the Sub name to
'test_initialize()' -- the blank userform popped rigtht up, but the
msgbox was totally skipped (even though no data was present).
Changing back to 'Userform_Initialize' fixed the problem ... is this
just a built-in property of userforms?

Please forgive the 'basic' questions ... I'm just starting to use
userforms!

TIA,
Ray


Private Sub Userform_Initialize()
Dim myR As Range
Dim myCell As Range
Dim mySA() As String
Dim i As Integer

On Error GoTo NoCells

Set myR = Worksheets("Admin").Range("G39:G68") _
.SpecialCells(xlCellTypeConstants)
' Load UserForm1
ReDim mySA(0 To myR.Cells.Count, 0 To 1)
On Error GoTo 0
i = 0
For Each myCell In myR
mySA(i, 0) = myCell.Value
mySA(i, 1) = myCell(1, 2).Value
i = i + 1
Next myCell
UserForm1.ListBox1.List = mySA
' UserForm1.Show

NoCells:
MsgBox "No stores were late!", vbExclamation
Exit Sub
End Sub

 
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
code modules included in sheet count? mark Excel Programming 6 June 5th 07 05:28 PM
how do i change or make this macro??? pictures and code included dispelthemyth Excel Programming 1 March 17th 06 01:56 PM
how do i change or make this macro??? pictures and code included dispelthemyth Charts and Charting in Excel 0 March 17th 06 01:02 AM
Run-time error '9' ---- Code to fix included. [email protected] Excel Programming 3 September 2nd 05 02:48 PM
Require extra funtionality - existing code included Hilton Excel Programming 0 October 7th 04 02:57 PM


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

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"