LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Newbie question regarding using Sub Worksheet_change()

Hi,

Column A contains X axis data
Column B contains Y axis data

Column C contains formula which depends on X and Y axis data

Now as I change Y value in excel I want Column C to be changed
automatically. I can do this without VBA by inserting the formula in
Column C but I was just wondering how it is possible in VBA. I tried
running the code inside the Sub Worksheet_change(by val target as
range) but whenever Y is changed C does not change. any idea where Im
going wrong.

Here is part of the code:

Private Sub Worksheet_Change(ByVal Target As Range)
' Say when I use Target.address ="$B$2" and change B2 in excel the code
runs, but I want to change any cell in column B, so how do I go about
it ? '

Dim S As Double, I As Double
Dim x As Integer
S = Application.WorksheetFunction.Slope(Range("G2:G7") , Range("F2:F7"))
I = Application.WorksheetFunction.Intercept(Range("G2: G7"),
Range("F2:F7"))
For x = 2 To 7
Cells(x, 3) = S * Cells(x, 2) + I ' This is column C which
should update according to the formula'
Next x

End Sub

Thanks
Titus

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Compile error: Ambigious name detected: Worksheet_Change **NEWBIE** Dan Excel Programming 3 May 26th 06 05:57 PM
Compile error: Ambigious name detected: Worksheet_Change **NEWBIE** dan Excel Discussion (Misc queries) 1 May 26th 06 10:13 AM
worksheet_change question HRman Excel Programming 2 March 30th 06 05:35 PM
Worksheet_Change procedure question Grant Excel Programming 0 October 1st 04 01:17 AM


All times are GMT +1. The time now is 01:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"