Upon opening worksheet check value is present in userform

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,222
Office Version
  1. 2007
Platform
  1. Windows
Afternoon,

When i open my worksheet i see a msgbox asking if the userform should be opened.
Clicking on Yes should only open the form if NameForDateEntryBox.Text has a value in it.

Below is my code attemp but returns variable not defined thus i dont see this msgbox question

Code:
Private Sub Worksheet_Activate()
Application.GoTo Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp).Offset(1, 0), True
ActiveWindow.SmallScroll UP:=14


Dim answer As Integer
 
answer = MsgBox("Open Postage User Form ?", vbYesNo + vbQuestion, "POSTAGE USER FORM MESSAGE")
If answer = vbYes And [COLOR=#ff0000]NameForDateEntryBox[/COLOR].Text = "" Then
Exit Sub
  PostageTransferSheet.Show
Else
  Exit Sub
End If
End Sub
 
Hi,

I already have a code using explicit.

Here it is below.

How / what should i now do,please advise thanks.

Code:
Option ExplicitPrivate Sub PostageCustomerDuplicateSearch_Click()


    Dim Cell As Variant
    Dim source As Range
    Dim dups As Long


    Set source = Range("B8:B5000")


    For Each Cell In source
        If Application.WorksheetFunction.CountIf(source, Cell) > 1 Then
            Cell.Interior.Color = RGB(0, 255, 0)
            dups = dups + 1
        End If
    Next Cell
    
    If dups > 0 Then
        MsgBox " DUPLICATES WERE FOUND AND HAVE BEEN HIGHLIGHTED ", vbExclamation, "POSTAGE DUPLICATE CHECKER"
    Else
        MsgBox " NO DUPLICATES WERE FOUND ", vbExclamation, "POSTAGE DUPLICATE CHECKER"
    End If


End Sub
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
.
This :

Code:
[COLOR=#333333]Option ExplicitPrivate Sub PostageCustomerDuplicateSearch_Click()[/COLOR]

Should be :

Code:
[COLOR=#333333]Option Explicit

Private Sub PostageCustomerDuplicateSearch_Click()

'rest of macro code.
[/COLOR]
 
Upvote 0
Hi,
It is but it just showed up as that due to it being pasted into the post
 
Upvote 0
.
Try without the OPTION EXPLICIT.

The macro works as presented .. here.
 
Upvote 0
I’ve ran out of time now and away working for one week.

I was hoping to get this fixed before I went it that was free case.

I will check upon my return

I don’t have excel on my laptop but so you know if something that will allow me to continue with this whilst away ?
 
Upvote 0
Your workbook has just been opened.
PostageTransferSheet is unloaded.
How would there be anything (except the default value) in any of the userform's controls?
 
Upvote 0
Morning,
I am now back & wishing to continue with this post.
Below is the code in use.

My aim is to only show userform if there are more than 1 name in the NameForDateEntryBox field

So i open my worksheet.
I see the msgbox asking if i would like to open the userform.
Selecting No would close the msgbox
Selecting Yes would then ONLY open the userform if there are more than 1 name in it.
If there is 1 name then show msgbox "No names Left"
Clicking Ok would then close msgbox

I see no other way to fix this so this will be the last attempt.

Code:
Private Sub Worksheet_Activate()
Application.GoTo Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp).Offset(1, 0), True
ActiveWindow.SmallScroll UP:=14


Dim answer As Integer
 
answer = MsgBox("Open Postage User Form ?", vbYesNo + vbQuestion, "POSTAGE USER FORM MESSAGE")
If answer = vbYes Then
PostageTransferSheet.Show
Else
  Exit Sub
End If
End Sub
 
Upvote 0
The logic of your desired action is flawed.
So i open my worksheet.
I see the msgbox asking if i would like to open the userform.
Selecting No would close the msgbox
Selecting Yes would then ONLY open the userform if there are more than 1 name in it.
At that point, the only entry in the userform would be the default entries. "if there are more than 1 name" would never change.
 
Upvote 0

Forum statistics

Threads
1,214,419
Messages
6,119,389
Members
448,891
Latest member
tpierce

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top