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: 47
Default Applying formulas if certain cells are changed

Hi

I'm trying to have my worksheet perform autoformulas in certain cells as
people keep adding lines to it, which blanks out the formula in the correct
cell, and then moaning because it doesn't work. Because of this I want to set
up a macro so that if they alter/change any details (even if they add a row
in the middle) the formula will be carried out.

I've got most of the macro nailed down but am having trouble with the SUMIF
in vba. (*** section)

U4:BL4 is a row of headings (many of which are repeated)
A2 is the selection I want look up
U3:BL4 is the row with the values I want to sum up
The 1st cell which will have this formula is in the fifth row.


Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Range(Target.Address), Range("A:EE")) _
Is Nothing Then

Dim r As Long
r = Target.Row

If Cells(r, "B").Value < "" Or _
Cells(r, "C").Value < "" Or _
Cells(r, "E").Value < "" Then
*** cells(r,"I").formula=SUMIF($U$4:$BL$4,$A$2,U5:BL5) ***
End If
End If
End Sub


However, I need the macro to be generic so the row number changes with the
cell which is selected. Something like below

cells(r,"I").formula=SUMIF($U$(r-1):$BL$(r-1),$A$2,Ur:BLr)

Any ideas?
 
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
Applying Formulas to a Range in a Worksheet Ra Excel Discussion (Misc queries) 4 June 15th 09 11:19 AM
applying formulas for all sheets selected emilr17 Excel Worksheet Functions 3 July 16th 08 06:46 PM
Applying formulas to filtered data Keith Excel Discussion (Misc queries) 4 August 2nd 07 05:02 PM
Applying Formulas to Visible Cells Only SteveC Excel Discussion (Misc queries) 7 June 26th 06 11:44 PM
Applying names to ranges of cells for formulas MMH Excel Programming 10 July 13th 05 09:58 PM


All times are GMT +1. The time now is 10:06 PM.

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

About Us

"It's about Microsoft Excel"