Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Trying2Learn
 
Posts: n/a
Default Forcing data value in a cell

Hello
I have a question. I have a spreadsheet with three columns. Only one of the
columns must contain 1 and other two will be then 0. I need to automate the
following tast:

If I input 1 in one cell (of any of the three columns), then others two
cells should automatically change their values to 0.

Any help in this matter will be appreciated.
Thanks.

Trying2Learn
  #2   Report Post  
Stefi
 
Posts: n/a
Default Forcing data value in a cell

Try this event routine (it works with columns A,B,C):

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
forcevalue = IIf(Target.Value = 1, 0, 1)
c = Target.Column
r = Target.Row
Select Case c
Case 1
Cells(r, 2).Value = forcevalue
Cells(r, 3).Value = forcevalue
Case 2
Cells(r, 1).Value = forcevalue
Cells(r, 3).Value = forcevalue
Case 3
Cells(r, 1).Value = forcevalue
Cells(r, 2).Value = forcevalue
End Select
Application.EnableEvents = True
End Sub

Warning: this macro assumes that you enter only 0 or 1.

Regards,
Stefi


€˛Trying2Learn€¯ ezt Ć*rta:

Hello
I have a question. I have a spreadsheet with three columns. Only one of the
columns must contain 1 and other two will be then 0. I need to automate the
following tast:

If I input 1 in one cell (of any of the three columns), then others two
cells should automatically change their values to 0.

Any help in this matter will be appreciated.
Thanks.

Trying2Learn

  #3   Report Post  
Trying2Learn
 
Posts: n/a
Default Forcing data value in a cell

Hello Stefi,

Thanks a lot for your help.

Trying2Learn

"Stefi" wrote:

Try this event routine (it works with columns A,B,C):

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
forcevalue = IIf(Target.Value = 1, 0, 1)
c = Target.Column
r = Target.Row
Select Case c
Case 1
Cells(r, 2).Value = forcevalue
Cells(r, 3).Value = forcevalue
Case 2
Cells(r, 1).Value = forcevalue
Cells(r, 3).Value = forcevalue
Case 3
Cells(r, 1).Value = forcevalue
Cells(r, 2).Value = forcevalue
End Select
Application.EnableEvents = True
End Sub

Warning: this macro assumes that you enter only 0 or 1.

Regards,
Stefi


€˛Trying2Learn€¯ ezt Ć*rta:

Hello
I have a question. I have a spreadsheet with three columns. Only one of the
columns must contain 1 and other two will be then 0. I need to automate the
following tast:

If I input 1 in one cell (of any of the three columns), then others two
cells should automatically change their values to 0.

Any help in this matter will be appreciated.
Thanks.

Trying2Learn

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
Input Cell in One variable data table Dottore Magistrale Excel Worksheet Functions 0 August 30th 05 06:25 PM
mass cell data editing George B. Excel Worksheet Functions 2 August 25th 05 08:23 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Repeat Cell Data Pinky Excel Worksheet Functions 1 January 18th 05 05:38 PM
sending data from one cell to another (not using copy & paste) Charlie Payne Excel Worksheet Functions 3 December 6th 04 03:28 PM


All times are GMT +1. The time now is 11:49 PM.

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"