help me with this marco

  • Thread starter Thread starter lwong
  • Start date Start date
L

lwong

Code
-------------------

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Cells(1, 1) <> "" Then
Cells(2, 2) = "jkdjkd"
End If
If Cells(2, 2) <> "" Then
Cells(3, 3) = "hihihi"
End If
End Sub
 
When your code changes the values of cells (2,2) and (3,3), this triggers
the Change event again.

You have to disable events before you change values in the worksheet:

'-----------
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.EnableEvents = False
If Cells(1, 1) <> "" Then
Cells(2, 2) = "jkdjkd"
End If
If Cells(2, 2) <> "" Then
Cells(3, 3) = "hihihi"
End If
Application.EnableEvents = False
End Sub
'---------------------------


HTH
 
thank you.
one more question, in the worksheet, A1 to A100 have different values
how to program if I want to set A1=c1 up to A100=C100?what is the code
 
if you mean you want c1:c100 equal to a1:a100

Range("c1:c100").Value = Range("a1:a100").Value
 
Thank you, actually I want to like this:
C1=Days360(A1,B1)
C2=Days360(A2,B1)
.....
C100=Days360(A100,B1)
When worksheet open,how?Thank you.

I have tried as this

Code:
--------------------

dim x as integer
for x=1 to 100
c&x="=days360(A&x,B1)"
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top