LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default running program from userform

Some time ago, in a series of threads, I learned that if a program is
always run in conjunction with a userform, the code should all be in
the userform, not in a module. I was too far along with the previous
program to re-write it all to be in the userform.

Now I'm writing another program that will only be run with the userform
(uf1021Mid), so I'm trying to write the code entirely in the userform.
So far, I have 2 problems. One is, how do I initiate a program in the
userform? Normally, when I initiate a program, I call it's name from
the macro menu or from a tool to which it's been assigned. Since the
code in the userform already has names like "Private Sub
btnCancel_Click()", I don't think I can call the program from those
names. So how do I access the macro? Maybe I misunderstood the previous
posts and there always has to be at least the Sub name and a userform
call in a module?

Second problem in testing to see if the refedit in the userform is
returning a range. I'm using the following code, the test code being
from Walkenbach's book:

Private Sub OKButton_Click()


Dim wbExtr As Workbook

Dim wsRef As Worksheet 'wks where Top 10 list is stored
Dim wsExtFrom As Worksheet 'Wks where data is extracted from
Dim wsTop As Worksheet 'wks where new table goes

Dim oWS As Object

Dim rCopy As Range
Dim rCell As Range 'each cell in rRef
Dim rRef As Range 'Range on wsRef where current CtyLst is
Dim rExtrFromStrt As Range
Dim rExtrFrom As Range 'range in Src sheet Where cty names are
Dim rRefRow As Range
Dim rExtrFromEnd As Range
'Dim rColHdr As Range
Dim rHdrStrt As Range
Dim rHdrEnd As Range

Dim s1stCtyName As String
Dim sUCrCell As String
Dim sCtyName As String
Dim sHeader As String

Dim lExtrFromCol As Long 'CtyCol in Src sht
Dim lExtrToCol As Long
Dim lTopRow As Long
Dim lCopyRow As Long
Dim lBOS10Row As Long
Dim lBOS21Row As Long
Dim lStrDif As Long
Dim lMid3Row As Long
Dim lBOS3Row As Long
Dim lRefRow As Long
Dim lExtrFromStrt As Long
Dim lColHdrCount As Long
Dim lLastCol As Long
Dim lLastRow As Long


Dim bHdr As Boolean

Set wsRef = Workbooks("Mark Top 10.xls").Worksheets("CtyLst")
Set wsExtFrom = ActiveSheet
Set wbExtr = ActiveWorkbook
lTopRow = 2
lBOS10Row = 14
lBOS21Row = 25
lMid3Row = 14
lBOS3Row = 27

'Test is Mark Top 10 workbook is active
If ThisWorkbook.Name = wbExtr.Name Then
MsgBox "You have selected the workbook that contains the macro." &
_
Chr(13) & "Please click Ok and select the correct workbook and " &
_
Chr(13) & "worksheet and restart the macro.", vbOKOnly
Exit Sub

End If



'TEST FOR SHEET NAMED "Top"
For Each oWS In wbExtr.Sheets
If oWS.Name = "Top" Then
If MsgBox("A worksheet named Top already exists in this
workbook." _
& Chr(13) & "Please remove or rename it and run the macro
again.", _
vbOKOnly) = vbOK Then Exit Sub
End If
Next
On Error Resume Next
'Set rColHdr = ActiveSheet.Range(reDataStrt.Text)
Set uf1021Mid.rColHdr = Range(reDataStrt.Text)

If Error < 0 Then
MsgBox "Invalid range selection, please select the starting range
again."
On Error GoTo 0
Exit Sub
End If
uf1021Mid.Hide
End Sub

No matter what I enter in the refedit control, I get the error message.
Any ideas?

Thanks as always.

 
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
Running program Greg[_32_] Excel Programming 1 October 24th 06 05:43 AM
Running a external Program MarkS Excel Programming 1 August 9th 06 08:25 AM
A program running on different Excel Versions Ian Stanborough Excel Programming 3 January 15th 05 05:06 AM
Stop a VB program from running Soterro Excel Programming 4 December 5th 03 07:25 PM
Running Program on a Mac ibeetb Excel Programming 0 October 16th 03 01:47 PM


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