#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Userform

Hi,

I have this code that I can't quite get right

If Not Intersect(Target, Range("emp_All")) Is Nothing Then
On Error Resume Next
If Range("A(ActiveCell.Row)") < "" Then
UserForm1.Show
End If
On Error GoTo 0
Else
On Error Resume Next
Unload UserForm1
Err.Clear
End If

It works except that it appears to ignore 'If Range("A(ActiveCell.Row)") <
"" ' and proceeds to show the UserForm even if range is empty.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Userform

Try

If Not Intersect(Target, Range("emp_All")) Is Nothing Then
On Error Resume Next
If Range("A" & Target.Row) < "" Then
UserForm1.Show
End If
On Error GoTo 0
Else
On Error Resume Next
Unload UserForm1
Err.Clear
End If

HTH

Bob


"LaDdIe" wrote in message
...
Hi,

I have this code that I can't quite get right

If Not Intersect(Target, Range("emp_All")) Is Nothing Then
On Error Resume Next
If Range("A(ActiveCell.Row)") < "" Then
UserForm1.Show
End If
On Error GoTo 0
Else
On Error Resume Next
Unload UserForm1
Err.Clear
End If

It works except that it appears to ignore 'If Range("A(ActiveCell.Row)")
<
"" ' and proceeds to show the UserForm even if range is empty.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Userform

Ok, got it now!

Range("A" & ActiveCell.Row) < ""

"LaDdIe" wrote:

Hi,

I have this code that I can't quite get right

If Not Intersect(Target, Range("emp_All")) Is Nothing Then
On Error Resume Next
If Range("A(ActiveCell.Row)") < "" Then
UserForm1.Show
End If
On Error GoTo 0
Else
On Error Resume Next
Unload UserForm1
Err.Clear
End If

It works except that it appears to ignore 'If Range("A(ActiveCell.Row)") <
"" ' and proceeds to show the UserForm even if range is empty.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Userform

hi
not sure but i get an error with your code. so i rewrote it to work on my pc.
Dim r As Long
r = ActiveCell.Row
If Range("A" & r) < "" Then

i think you have a syntax problem'
regards
FSt1


"LaDdIe" wrote:

Hi,

I have this code that I can't quite get right

If Not Intersect(Target, Range("emp_All")) Is Nothing Then
On Error Resume Next
If Range("A(ActiveCell.Row)") < "" Then
UserForm1.Show
End If
On Error GoTo 0
Else
On Error Resume Next
Unload UserForm1
Err.Clear
End If

It works except that it appears to ignore 'If Range("A(ActiveCell.Row)") <
"" ' and proceeds to show the UserForm even if range is empty.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Userform

This is just a suggestion. I'm not a big fan of using On Error Resume Next.
You are only asking for trouble. 99.999% of the time you can avoid using the
syntax. I would do this instead. This code will test if the Userform you
want to unload is loaded before you Unload it. Hope this helps! If so, let
me know, click "YES" below.

Sub TEST()

If Not Intersect(Target, Range("emp_All")) Is Nothing Then
If Range("A" & ActiveCell.Row) < "" Then UserForm1.Show
Else
If IsUserFormLoaded(UserForm1) Then Unload UserForm1
End If

End Sub

' Rick Rothsteins code
Function IsUserFormLoaded(UserFormName As String) As Boolean

Dim UF As Object

For Each UF In UserForms
If UCase(UF.Name) = UCase(UserFormName) Then
IsUserFormLoaded = True
Exit Function
End If
Next UF

End Function
--
Cheers,
Ryan


"LaDdIe" wrote:

Ok, got it now!

Range("A" & ActiveCell.Row) < ""

"LaDdIe" wrote:

Hi,

I have this code that I can't quite get right

If Not Intersect(Target, Range("emp_All")) Is Nothing Then
On Error Resume Next
If Range("A(ActiveCell.Row)") < "" Then
UserForm1.Show
End If
On Error GoTo 0
Else
On Error Resume Next
Unload UserForm1
Err.Clear
End If

It works except that it appears to ignore 'If Range("A(ActiveCell.Row)") <
"" ' and proceeds to show the UserForm even if range is empty.

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
fill userform textbox from userform listbox clik event GregJG[_21_] Excel Programming 3 December 7th 08 04:47 PM
Is there an easy Copy/Paste of a Userform ? (Entire Userform Including tx & cbx's) Corey Excel Programming 2 January 9th 07 01:01 PM
Userform to enter values and shown in same userform in list helmekki[_104_] Excel Programming 0 November 19th 05 03:23 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM


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