Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Delete the contents of a cell under multiple conditions

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Delete the contents of a cell under multiple conditions

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




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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Delete the contents of a cell under multiple conditions

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Delete the contents of a cell under multiple conditions

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:")

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
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
Can I delete a portion of cell contents repeating in multiple fie. katkim Excel Discussion (Misc queries) 1 February 19th 10 04:25 PM
delete contents of cell RDC Excel Discussion (Misc queries) 1 January 21st 09 04:13 PM
Delete Cell Contents IF joecrabtree Excel Programming 3 December 18th 06 02:21 PM
Formula to return cell contents based on multiple conditions Bill Excel Worksheet Functions 3 January 19th 05 09:59 AM
entirerow.delete multiple text conditions Jocelyn[_3_] Excel Programming 3 February 9th 04 05:58 PM


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