Page 1 of 1
excel and VBA code
Posted: April 3rd, 2006, 2:04 pm
by jaccker
I have a question about the using of Excel and VBA.Lets say in cell A1 and A2, I input 1 and 2. Then I input formula =SUM(A1+A2) to cell A3.I would like to write a VBA code to have the following functionality:Once I change the formula in A3, lets say I input 4 to cell A3, the color of the cell A3 should be changed. Once I double click the changed cell A3, it should recover to the formula =SUM(A1+A2). Anybody could help me out to solve the problem? How to write the VBA marcos?Thank you
excel and VBA code
Posted: April 3rd, 2006, 2:12 pm
by bluetrin
QuoteOriginally posted by: jacckerI have a question about the using of Excel and VBA.Lets say in cell A1 and A2, I input 1 and 2. Then I input formula =SUM(A1+A2) to cell A3.I would like to write a VBA code to have the following functionality:Once I change the formula in A3, lets say I input 4 to cell A3, the color of the cell A3 should be changed. Once I double click the changed cell A3, it should recover to the formula =SUM(A1+A2). Anybody could help me out to solve the problem? How to write the VBA marcos?Thank youPress ALT+F11, Open Sheet1 (or whatever worksheet you have edited) and using the top combobox, edit the events associated the worksheet.if you copy/paste this sample, it will pop a msgbox when you double click or edit a3:Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not (Intersect(Range("A3"), Target) Is Nothing) Then MsgBox "A3 has been double clicked" End If Range("A1").SelectEnd SubPrivate Sub Worksheet_Change(ByVal Target As Range) If Not (Intersect(Range("A3"), Target) Is Nothing) Then MsgBox "A3 has been edited" End IfEnd Sub
excel and VBA code
Posted: April 4th, 2006, 10:04 am
by Wibble
have a look at this site for some useful tipshttp://
www.ozgrid.com/Excel/excel-faq.htm
excel and VBA code
Posted: November 24th, 2006, 3:53 am
by saini
QuoteOriginally posted by: bluetrinQuoteOriginally posted by: jacckerI have a question about the using of Excel and VBA.Lets say in cell A1 and A2, I input 1 and 2. Then I input formula =SUM(A1+A2) to cell A3.I would like to write a VBA code to have the following functionality:Once I change the formula in A3, lets say I input 4 to cell A3, the color of the cell A3 should be changed. Once I double click the changed cell A3, it should recover to the formula =SUM(A1+A2). Anybody could help me out to solve the problem? How to write the VBA marcos?Thank youPress ALT+F11, Open Sheet1 (or whatever worksheet you have edited) and using the top combobox, edit the events associated the worksheet.if you copy/paste this sample, it will pop a msgbox when you double click or edit a3:Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not (Intersect(Range("A3"), Target) Is Nothing) Then MsgBox "A3 has been double clicked" End If Range("A1").SelectEnd SubPrivate Sub Worksheet_Change(ByVal Target As Range) If Not (Intersect(Range("A3"), Target) Is Nothing) Then MsgBox "A3 has been edited" End IfEnd Sub