PDA

View Full Version : Please help me edit code



etheer
11-17-2012, 06:53 AM
HI
I have code paste cell to another cell
code work very good when i change in cell F normal
but when i change in sheet M2 do not work code
plaese help me

etheer
11-17-2012, 07:13 AM
Why i need change normal cell F to work code
i need work code if change cell in sheet M2

mancubus
11-17-2012, 07:53 AM
welcome to the forum.

what you are using is worksheet specific event code.

hit Alt+F11 to open VBE.
double click on Sheet1(M1). select all the code in the code window (which is on the right).
copy it (ctrl+C)

double click on Sheet2(M). go to code window.
paste it (ctrl+V)

save your file.

etheer
11-17-2012, 08:09 AM
welcome to the forum.

what you are using is worksheet specific event code.

hit Alt+F11 to open VBE.
double click on Sheet1(M1). select all the code in the code window (which is on the right).
copy it (ctrl+C)

double click on Sheet2(M). go to code window.
paste it (ctrl+V)

save your file. HI mancubus
you download book1a and you understand what i mean

now when i change in sheet M2
change cell F in M1 and change cell J to yes but code do not work
if i change normal cell F change cell J to yes and work code
i need work code when i change in sheet M2

mancubus
11-17-2012, 09:06 AM
so you want changes in Column A of M2 take effect in M1?

goes to M2's worksheet code module:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim c As Range

If Not Intersect(Target, Range("A:A")) Is Nothing Then
On Error Resume Next
For Each c In Worksheets("M1").Range("J7:J" & Worksheets("M1").Cells(Rows.Count, "J").End(xlUp).Row)
If c = "Yes" Then
With c
.Offset(, 1).Value = "Yes"
.Offset(, 2).Value = .Offset(, -6).Value
End With
End If
Next c
End If

End Sub

etheer
11-17-2012, 09:36 AM
Thank you so much mancubus

etheer
11-17-2012, 09:37 AM
so you want to control changes in Column A of M2 take effect in M1?

goes to M2's worksheet code module:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim c As Range

If Not Intersect(Target, Range("A:A")) Is Nothing Then
On Error Resume Next
For Each c In Worksheets("M1").Range("J7:J" & Worksheets("M1").Cells(Rows.Count, "J").End(xlUp).Row)
If c = "Yes" Then
With c
.Offset(, 1).Value = "Yes"
.Offset(, 2).Value = .Offset(, -6).Value
End With
End If
Next c
End If

End Sub



Thank you so much mancubus

mancubus
11-17-2012, 09:39 AM
you're wellcome.