LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Excel VBA

Bob Phillips wrote:
Just use Public variables


And for those of us who shun Public variables <g, create a Public
Property for the userform, prevent the userform from unloading itself
(hide it instead) and test the value of the Property e.g.

' ---<Userform1 code module---
Option Explicit
Private m_foundCell As Range

Private Function FindCell()
' Code to find cell goes here e.g.
Set m_foundCell = Range("A1")
End Function

Public Property Get foundCell() As Range
Set foundCell = m_foundCell
End Property

Private Sub UserForm_QueryClose( _
Cancel As Integer, _
CloseMode As Integer)
Me.Hide
Cancel = True
End Sub
' ---</Userform1 code module---

' ---<Calling code ---
Sub test()
Dim rng As Range
Dim thing As UserForm1
Set thing = New UserForm1
With thing
.Show vbModal
Set rng = .foundCell
End With
Set thing = Nothing

' code continues ...
If rng Is Nothing Then
End If

End Sub

Jamie.

--

 
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



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