PC Review


Reply
Thread Tools Rate Thread

Delete the contents of a cell under multiple conditions

 
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      22nd Jan 2007
If cell A1=1, A1=3 or A1=5, I want the existing contents of B1 to be
deleted. However, if A1=2 or A1=4, I want to be able to enter input
into B1. Can someone suggest a macro for this? Thanks.

Michael

 
Reply With Quote
 
 
 
 
okrob
Guest
Posts: n/a
 
      22nd Jan 2007
Try this:
Public Sub test()
Dim Cvalue As Double
Cvalue = Range("A1").Value
On Error GoTo test_Error
Select Case Cvalue
Case 1
Range("B1").ClearContents
Case 2
Range("B1").Value = Application.InputBox("Input value for
B1")
Case 3
Range("B1").ClearContents
Case 4
Range("B1").Value = Application.InputBox("Input value for
B1")
Case Else
Exit Sub
End Select
On Error GoTo 0
Exit Sub

test_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure test of Module Module1"
End Sub


Rob




(E-Mail Removed) wrote:
> If cell A1=1, A1=3 or A1=5, I want the existing contents of B1 to be
> deleted. However, if A1=2 or A1=4, I want to be able to enter input
> into B1. Can someone suggest a macro for this? Thanks.
>
> Michael


 
Reply With Quote
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      22nd Jan 2007
Thanks Gary's Studuent and Rob,

It looks like I've got 2 promising possibilities. However, as a
novice, I'm a little confused over someting you both have indicated.
In both solutions, I need to enter a value for B1. What I need to
reflect is any value greater than 0. How specifically would I state
this? Rather, how would it appear? Thanks again.

Michael

 
Reply With Quote
 
okrob
Guest
Posts: n/a
 
      22nd Jan 2007
Your original post:
---------------------------------
If cell A1=1, A1=3 or A1=5, I want the existing contents of B1 to be
deleted. However, if A1=2 or A1=4, I want to be able to enter input
into B1. Can someone suggest a macro for this? Thanks.

Michael
---------------------------------

It looked to me like you wanted the user to be prompted to input a
value for B1. If this is not the case, what exactly do you want the
cell in B1 to do if A1 is 2 or 4?

Basically, if the value for B1 doesn't matter, you can just delete this
line from Gary''s Student's code:
Range("B1").Value = Application.InputBox("Enter a value for B1:")

(E-Mail Removed) wrote:
> Thanks Gary's Studuent and Rob,
>
> It looks like I've got 2 promising possibilities. However, as a
> novice, I'm a little confused over someting you both have indicated.
> In both solutions, I need to enter a value for B1. What I need to
> reflect is any value greater than 0. How specifically would I state
> this? Rather, how would it appear? Thanks again.
>
> Michael


 
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
Can I delete a portion of cell contents repeating in multiple fie. katkim Microsoft Excel Misc 1 19th Feb 2010 04:25 PM
Multiple conditions to a formula in one cell Audra Microsoft Excel Misc 4 20th Oct 2008 05:40 PM
Multiple Conditions in a cell =?Utf-8?B?TWF5YQ==?= Microsoft Excel Worksheet Functions 3 10th Jun 2005 11:51 PM
Formula to return cell contents based on multiple conditions =?Utf-8?B?QmlsbA==?= Microsoft Excel Worksheet Functions 3 19th Jan 2005 09:59 AM
entirerow.delete multiple text conditions Jocelyn Microsoft Excel Programming 4 9th Feb 2004 05:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:20 PM.