automatic rules in excel to insert value in a cell relative to a reference cell

desmond_

Board Regular
Joined
Jan 4, 2017
Messages
59
Dear Experts,

i wanted to create a timetable in which i only have to insert "x" in a cell and it will automatically insert "xzy" 10 cells to the left/right of where i have entered "x"

is something like this possible ?

here an example of what i mean;
i just need to insert x and xyz will be inserted always 10 cells to the right or left
xxyz
xxyz

<tbody>
</tbody>




its probably a very basic function in excel for project management but i couldnt find any information

thanks in advance
Regards dezmond
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
The following code would go into the code module of the worksheet you are working on.
The Worksheet_Change event is what "automatically" does the work.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Value = "x" Then
Cells(Target.Row, Target.Column + 10).Value = "xyz"
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Hi,
that works perfectly fine.
do you have a recommendation on how to apply this rule only on a specific range ?

thanks a lot

Regards Dezmond
 
Upvote 0
Just nest the If for Target.value in another If statement.
Choices can be Target.Column, Target.Row, Target.Address, Target.Range
There are lots of great examples on this forum or try online search, you'll quickly find just what you are looking for.
Regards
 
Upvote 0
got it, i have managed to define the range by using Not Intersect(Target, Range)
however, now i end up with the question -> how can i clear the cells if i delete the previously entered "x" ?

if target.value = "" then
Cells(Target.Row,Target.Column +10).Value = ""

doesn't really work (...)
any suggestion for that ?


Regards Des
 
Upvote 0

Forum statistics

Threads
1,216,058
Messages
6,128,538
Members
449,456
Latest member
SammMcCandless

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top