Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Message box before another macro

I need to add a message box to the front end of a search macro that
will trigger based on certain criteria and, in the absence of those
criteria, allow the macro to proceed. Sounds like a simple
"IF..Then..Else", but I cannot get the syntax to agree, even after
pouring through this group and using previously suggested solutions.

I need this:

If Range("Q55") = "True" Then
MsgBox"blah blah blah"

Else RunMacro1

VB kicks back a "Type Mismatch" every time on the very first statement
here. I have tried the True with and without quotes, same result.

Entire code is below. Help is appreciated.

Sub Look_Here1()

If Range("Q55") = "true" Then
MsgBox "Check Driver's License Expiration Date", 48, "Exprired
Driver's License"

Else
Dim FoundCell As Range
Dim WhatFor As Variant
WhatFor = ActiveSheet.Cells(7, 2).Value

Set FoundCell = Range("B8:B990").Find(What:=WhatFor,
after:=ActiveCell, _
SearchDirection:=xlNext, searchorder:=xlByRows,
_
MatchCase:=False)

If FoundCell Is Nothing Then
Range("A7").Select
ActiveCell.FormulaR1C1 = "X"
Range("D7").Select

Else

FoundCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "X"
Selection.Offset(0, 4).Select

End If
End If


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
mrice
 
Posts: n/a
Default Message box before another macro


Try the True without the quotes to get the value as opposed to a string.


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=544103

  #3   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Message box before another macro

Still give me a "Type Mismatch"

Thanks for looking.

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Message box before another macro

What's in Q55?

maybe...

if lcase(range("q55").text) = "true" then

I'm guessing that you had an error #ref, #n/a, div/0, ... in that cell.

michaelberrier wrote:

I need to add a message box to the front end of a search macro that
will trigger based on certain criteria and, in the absence of those
criteria, allow the macro to proceed. Sounds like a simple
"IF..Then..Else", but I cannot get the syntax to agree, even after
pouring through this group and using previously suggested solutions.

I need this:

If Range("Q55") = "True" Then
MsgBox"blah blah blah"

Else RunMacro1

VB kicks back a "Type Mismatch" every time on the very first statement
here. I have tried the True with and without quotes, same result.

Entire code is below. Help is appreciated.

Sub Look_Here1()

If Range("Q55") = "true" Then
MsgBox "Check Driver's License Expiration Date", 48, "Exprired
Driver's License"

Else
Dim FoundCell As Range
Dim WhatFor As Variant
WhatFor = ActiveSheet.Cells(7, 2).Value

Set FoundCell = Range("B8:B990").Find(What:=WhatFor,
after:=ActiveCell, _
SearchDirection:=xlNext, searchorder:=xlByRows,
_
MatchCase:=False)

If FoundCell Is Nothing Then
Range("A7").Select
ActiveCell.FormulaR1C1 = "X"
Range("D7").Select

Else

FoundCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "X"
Selection.Offset(0, 4).Select

End If
End If


End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Message box before another macro

Q55 is a True/False based on a date entered in another cell.

Basically, if that date is after today, then Q55 is false and the macro
completes. Conversely, if Q55 is True, then I want the Message Box to
display.

Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Message box before another macro

That code is looking at the activesheet.

Are you sure that's the one you wanted?

maybe adding:

msgbox range("q55").text

would help you debug the problem.

michaelberrier wrote:

Q55 is a True/False based on a date entered in another cell.

Basically, if that date is after today, then Q55 is false and the macro
completes. Conversely, if Q55 is True, then I want the Message Box to
display.

Thanks.


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Message box before another macro

It is the activesheet that I want.

Where would I add msgbox range("Q55").text?

  #8   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Message box before another macro

right before the if statement.

You'd be using it just to help debug the problem.

msgbox range("q55").text
if range("q55").value = True then
.....

michaelberrier wrote:

It is the activesheet that I want.

Where would I add msgbox range("Q55").text?


--

Dave Peterson
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
Row Expansion Susan Excel Worksheet Functions 11 February 28th 06 07:15 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Macro message box ynissel Excel Discussion (Misc queries) 7 July 18th 05 06:50 PM
Macro - message box if find nothing Frantic Excel-er Excel Discussion (Misc queries) 8 July 1st 05 08:45 PM


All times are GMT +1. The time now is 01:04 AM.

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"