PDA

View Full Version : VBA MAcros for Calculation of multi columns



hecgroups
03-10-2012, 10:58 AM
Hello,

I an seeking a help to amendment in a VBA Macros. This micros written by one of my friend. But now the problem is below mentioned script is working for columns C,D & F only.

What i need here is Same calculation also work for columns I, J, L,P, Q, S, V,W Y.

Can anyone help me to resolve this issue please.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim keyRange As Range, changedRange As Range
Dim oneArea As Range, oneRow As Range
Dim Dent As Double, Lim As Double, newLim As Double
Dim Pct As Variant, Increase As Variant, Differential As Variant

Set keyRange = Range("C:C,D:D,F:F")
Set changedRange = Application.Intersect(keyRange.EntireColumn, Target)

If Not changedRange Is Nothing Then
On Error GoTo ErrorOut
Application.EnableEvents = False
With changedRange
For Each oneArea In .Areas
With oneArea
For Each oneRow In oneArea.Rows

With oneRow.EntireRow
Dent = Val(CStr(.Range("c1")))
Lim = Val(CStr(.Range("d1")))
newLim = Val(CStr(.Range("F1")))
If Lim <> 0 Then
Pct = Dent / Lim
If newLim <> 0 Then
Increase = Pct * newLim
Differential = Increase - Dent
End If
End If
.Range("e1") = Pct: .Range("g1") = Increase: .Range("H1") = Differential
End With

Next oneRow
End With
Next oneArea
End With
End If
ErrorOut:
Application.EnableEvents = True
End Sub

mikerickson
03-11-2012, 12:11 AM
Welcome hecgroups,

This is cross-posted at
http://www.excelforum.com/excel-programming/816230-formula-calculation-from-multi-cell-to-1-a.html

And you haven't made a responce to the last reply at
http://www.mrexcel.com/forum/showthread.php?t=620233

Please read this:

http://www.excelguru.ca/content.php?184

It explains why the rules about cross-posting are important to us and to you.

hecgroups
03-11-2012, 10:26 AM
sorry i forget.

i got solution on mrexcel.com and waiting for response.

hecgroups
03-15-2012, 06:14 AM
I got the solution how can i marked this topic as solved to save other members time.

Bob Phillips
03-15-2012, 06:40 AM
There is a dropdown called Thread Tools at the top of all threads. It is in there.

hecgroups
03-15-2012, 10:38 AM
Its their but there is option to edit the topic to make changes

Bob Phillips
03-15-2012, 10:43 AM
You don't edit, just mark as solved.