Calculate specific column with VBA

Russk68

Active Member
Joined
May 1, 2006
Messages
477
Hi all

I want to calculate only column B whenever a change is made in column A.

Thank you!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,111
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
If it's directly connected, could you not use a formula for each row ??
Without knowing what calculation is required, a macro would seem like overkill !
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,417
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Be aware that once triggered, this event macro will leave calculation set to manual.
Code:
Dim R As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set R = Selection.Cells(1, 1)
Application.Calculation = xlCalculationManual
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(R, Target) Is Nothing Then
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
        Range("B:B").Calculate
    End If
End If
End Sub
 

Russk68

Active Member
Joined
May 1, 2006
Messages
477
Hi Michael

The issue that I'm trying to escape, is having the workbook calculate everytime that I make an entry in column A. It takes a couple of seconds after every entry. I'm hoping that if only column B calculates, it will speed up the data entry process. Its a complex workbook and I'm using column A & B as just an example.

Thanks!
 

Russk68

Active Member
Joined
May 1, 2006
Messages
477

ADVERTISEMENT

Hi Joe
I pasted the code in the worksheet that I'm working on and I got this error.

Compile error:

Ambiguous name detected: Worksheet_Change
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,111
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
The error is because you can't have 2 seperate worksheet_change events.
You will either need to merge the events OR remove one of them
 
Last edited:

Russk68

Active Member
Joined
May 1, 2006
Messages
477

ADVERTISEMENT

Ah
I'll give it a shot.
Thanks!
 

Watch MrExcel Video

Forum statistics

Threads
1,129,312
Messages
5,635,497
Members
416,860
Latest member
coen078

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top