PC Review


Reply
Thread Tools Rate Thread

Check Cell Content before continuing...

 
 
=?Utf-8?B?Q2hyaXMgVC1N?=
Guest
Posts: n/a
 
      30th Oct 2007
Cells A1, & B1 contain pulldowns requesting input. My macro needs to check if
these cells still contain the original question, or any selection... IF new,
then continue macro. IF unchanged, then display error... I believe I know how
to present the error message, but I am unsure how to check the cells content.
(New to VBA, please include the basics. Thanks in advance.)
 
Reply With Quote
 
 
 
 
Bill Renaud
Guest
Posts: n/a
 
      31st Oct 2007
Try something like this (untested): Replace A1OriginalValue and
B1OriginalValue with your actual values (numbers, strings, etc.).

If Range("A1").Value = A1OriginalValue Or _
Range("B1").Value = B1OriginalValue _
Then
MsgBox "Error. Cell A1 and/or B1 has not changed.", _
vbCritical + vbOKOnly, _
"Check Cell A1 and B1"
Else
'Do macro.
End If


--
Regards,
Bill Renaud



 
Reply With Quote
 
=?Utf-8?B?Q2hyaXMgVC1N?=
Guest
Posts: n/a
 
      31st Oct 2007
I'm sorry, I ran into a compile error on my syntax right away. Any advice?

If Range("Q44").Value = "Fill in..." Or _
Range("F47").Value = Range("AB2").Value _

Thank you for your patience.
Christopher McCune

"Bill Renaud" wrote:

> Try something like this (untested): Replace A1OriginalValue and
> B1OriginalValue with your actual values (numbers, strings, etc.).
>
> If Range("A1").Value = A1OriginalValue Or _
> Range("B1").Value = B1OriginalValue _
> Then
> MsgBox "Error. Cell A1 and/or B1 has not changed.", _
> vbCritical + vbOKOnly, _
> "Check Cell A1 and B1"
> Else
> 'Do macro.
> End If
>
>
> --
> Regards,
> Bill Renaud
>
>
>
>

 
Reply With Quote
 
Bill Renaud
Guest
Posts: n/a
 
      31st Oct 2007
Your code (as follows) compiles and runs fine on my machine (Excel 2000):

Sub Test()
If Range("Q44").Value = "Fill in..." Or _
Range("F47").Value = Range("AB2").Value _
Then
MsgBox "Then"
Else
MsgBox "Else"
End If
End Sub

I don't know how the "Fill in..." will work, however. Maybe it appears this
way in the cell, but the full value is something longer (?).
--
Regards,
Bill Renaud



 
Reply With Quote
 
=?Utf-8?B?Q2hyaXMgVC1N?=
Guest
Posts: n/a
 
      31st Oct 2007
I'm not sure what I did, but your version works. (What was changed?)

Can you tell me how to stop the Macro if the 'then' condition is met, and
continue if it isn't?

Thank you,
Christopher McCune
PS: "Fill in..." is the cell's content. It's specific label is next to it.

"Bill Renaud" wrote:

> Your code (as follows) compiles and runs fine on my machine (Excel 2000):
>
> Sub Test()
> If Range("Q44").Value = "Fill in..." Or _
> Range("F47").Value = Range("AB2").Value _
> Then
> MsgBox "Then"
> Else
> MsgBox "Else"
> End If
> End Sub
>
> I don't know how the "Fill in..." will work, however. Maybe it appears this
> way in the cell, but the full value is something longer (?).
> --
> Regards,
> Bill Renaud
>
>
>
>

 
Reply With Quote
 
Bill Renaud
Guest
Posts: n/a
 
      1st Nov 2007
<<Can you tell me how to stop the Macro if the 'then' condition is met, and
continue if it isn't?>>

Leave the 'then' condition empty and have code in the 'else' part of the
clause only, or revise the logic as follows:

Sub Test()
If Range("Q44").Value <> "Fill in..." And _
Range("F47").Value <> Range("AB2").Value _
Then
'Your code here.
End If
End Sub

Except that your OP (original post) said:
<<IF new, then continue macro. IF unchanged, then display error... >>
--
Regards,
Bill Renaud



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check for wrong cell content Oldjay Microsoft Excel Programming 1 3rd May 2008 02:08 PM
Check if content in cell is an integer prem Microsoft Excel New Users 6 1st May 2008 01:54 PM
RE: Check if content in cell is an integer Mike H Microsoft Excel New Users 0 1st May 2008 09:53 AM
Check if cell content changed bbussoloti Microsoft Excel Programming 4 7th Dec 2007 05:07 PM
VBA cell content check =?Utf-8?B?RGVyZWsgV2l0dG1hbg==?= Microsoft Excel Programming 7 6th Sep 2006 07:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:47 PM.