|
-
April 20th, 2006, 10:59 PM
#1
help with excel macro
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim x
For x = 1 To 1000
If Cells(1, 1) <> "" Then
Cells(2, 1) = "hi"
End If
If Cells(2, 2) <> "" Then
Cells(3, 2) = "hello"
End If
End Sub
When I run this code, the cpu become busy, what happen? thank you.
Last edited by lwong; April 20th, 2006 at 11:55 PM.
-
April 20th, 2006, 11:46 PM
#2
Re: help with excel macro
You can record a macro in Excel and then you can look at the VB code that was generated.
-
April 21st, 2006, 12:03 AM
#3
Re: help with excel macro
I know, but what event can do that? when cell A change value, cell B also immediately changed value
-
April 21st, 2006, 01:52 AM
#4
Re: help with excel macro
Hi
What happen is, every time time you check cells(1,1).value you set cells(2,1).value to "HI", which will fire the Workbook_SheetChange event and then it will run sub again and never stop.
Cheers Karsten
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|