Serving the Quantitative Finance Community

 
User avatar
jaccker
Topic Author
Posts: 1
Joined: July 18th, 2004, 9:36 pm

excel and VBA code

April 3rd, 2006, 2:04 pm

I have a question about the using of Excel and VBA.Let’s 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, let’s 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
 
User avatar
bluetrin
Posts: 2
Joined: September 9th, 2005, 6:41 am

excel and VBA code

April 3rd, 2006, 2:12 pm

QuoteOriginally posted by: jacckerI have a question about the using of Excel and VBA.Let’s 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, let’s 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
 
User avatar
Wibble
Posts: 1
Joined: January 23rd, 2004, 3:15 pm

excel and VBA code

April 4th, 2006, 10:04 am

have a look at this site for some useful tipshttp://www.ozgrid.com/Excel/excel-faq.htm
 
User avatar
saini
Posts: 0
Joined: November 23rd, 2006, 11:20 am

excel and VBA code

November 24th, 2006, 3:53 am

QuoteOriginally posted by: bluetrinQuoteOriginally posted by: jacckerI have a question about the using of Excel and VBA.Let’s 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, let’s 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