Macro Calculation Help

beantownmt

New Member
Joined
Aug 29, 2011
Messages
11
Hi All.
I'm Having a problem with getting my Macro to auto update my field calculations once items are imported from Sheet1 to Sheet2
Here's the Code I'm using.

This Works Correctly
Application.EnableEvents = False
r = rngCell.Row
'u = Sheets("JeffsTransp").Range("B" & Rows.Count).End(xlUp).Row + 1

Sheets("JeffsTransp").Rows(u & ":" & u).Insert Shift:=xlDown
Sheets("JeffsTransp").Range("B" & u) = Sheets("Sheet1").Range("B" & r)
Sheets("JeffsTransp").Range("D" & u) = Sheets("Sheet1").Range("K" & r)
Sheets("JeffsTransp").Range("E" & u) = Sheets("Sheet1").Range("C" & r)
Sheets("JeffsTransp").Range("F" & u) = Sheets("Sheet1").Range("D" & r)
Sheets("JeffsTransp").Range("G" & u) = Sheets("Sheet1").Range("E" & r)
Sheets("JeffsTransp").Range("H" & u) = Sheets("Sheet1").Range("F" & r)
Sheets("JeffsTransp").Range("J" & u) = Sheets("Sheet1").Range("G" & r)
Sheets("JeffsTransp").Range("K" & u) = Sheets("Sheet1").Range("H" & r)
Sheets("JeffsTransp").Range("L" & u) = Sheets("Sheet1").Range("N" & r)
Sheets("JeffsTransp").Range("O" & u) = Sheets("Sheet1").Range("I" & r)
Sheets("JeffsTransp").Range("S" & u) = Sheets("Sheet1").Range("L" & r)
Application.EnableEvents = True
u = u + 1
'rngStart.PasteSpecial (xlPasteValuesAndNumberFormats)

Next rngCell
'restore screen updating

MsgBox "Limo Wiz Records to be Imported = " & n

I can not get these calculations to work after fields are imported
Cells(Target.Row, 1).Formula = "=A4+A15+1" 'Auto Line Number
Cells(Target.Row, 14).Formula = "=K16*L16" 'Gratutity Calculation
Cells(Target.Row, 16).Formula = "=K16+N16" 'Gross Recpts w Grats
Cells(Target.Row, 18).Formula = "=SUM(K16+O16)*Q16" 'Lease Rate
Cells(Target.Row, 20).Formula = "=R16*S16" 'Sales Tax Due
Cells(Target.Row, 21).Formula = "=SUM(P16-R16-T16)+M16" 'Exchange back with Grat

Application.ScreenUpdating = True
Exit Sub

Any help would be gratly appreciated.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Looks right to me.

any chance those cells are formatted as text? Are you sure that your range 'Target' is set?
 
Upvote 0
they are formatted as numbers and the range is set correctly.
When I run the auto import It won't run the calculations?
I'm at a loss..
 
Upvote 0
Try forcing a calculation at the end of your macro?
Sheets("JeffsTransp").Calculate


I'm thinking that maybe with events turned off while you update, it's not noting that any dependant cells need to be recalculated.

(tried on 2007, and it did update formulas... so this is just another guess)
 
Upvote 0
I'm still at a loss. Any other suggestions?
I tried the following,

Sheets("JeffsTransp").Calculate Cells(Target.Row, 1).Formula = "=A4+A16+1"
Sheets("JeffsTransp").Calculate Cells(Target.Row, 13).Formula = "=K16*L16"
Sheets("JeffsTransp").Calculate Cells(Target.Row, 15).Formula = "=K16+N16"
Sheets("JeffsTransp").Calculate Cells(Target.Row, 17).Formula = "=SUM(K16+O16)*Q16"
Sheets("JeffsTransp").Calculate Cells(Target.Row, 19).Formula = "=R16*S16"
Sheets("JeffsTransp").Calculate Cells(Target.Row, 20).Formula = "=SUM(P16-R16-T16)+M16"

Application.ScreenUpdating = True
Exit Sub
Unless I've set the formula up incorrectly? Any Help at this point would be great.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
rootytrip

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
Back
Top