macro to be edited.

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
This is what I have to do to the data I receive. As it is a regular routine, I thought of creating a macro which will finish this work in seconds.

I am sending the original data file along with the data with calculation. The yellow data is the data caclulated by a macro shared by Glenn,

As the number of rows change in every sheet, I would like to edit the macro by writing a code in the beginning, when I keep the cursor in Cell F2, it should do down to the last empty cell offset by 2nd blank cell in column F and offset to right. If the calculation is done with the help of a new macro it will be very helpful.

I will make sure that the columns are arranged the same way as in the code but the rows may vary from 800 - 2000 lines.
Herewith, I am sharing both the data, the original one and the one to be run with the macro.
Partly solved for Calculation by macro.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1Original Data >>>>>GrossABCDEFGHIJKLMNOPQRSTR/o
23090.00254.00719.00794.00845.006.356.3543.1443.1471.4671.46118.30118.30-0.50
31518.00140.00998.00198.003.503.5059.8859.8827.7227.72-0.20
41894.00483.00504.00619.0012.0812.0845.3645.3686.6686.66-0.19
51710.00214.00368.00838.005.355.3522.0822.08117.32117.320.50
61977.00701.00835.00259.0017.5317.5350.1050.1023.3123.310.13
71880.00537.00180.00833.0032.2232.2216.2016.20116.62116.62-0.08
81580.00715.00702.0017.8817.8863.1863.180.89
92307.00526.00409.00931.00155.0013.1513.1524.5424.5483.7983.7921.7021.70-0.36
10977.00828.0074.5274.52-0.04
11730.00103.00475.0018.54133.000.46
121222.00434.00684.0021.7082.080.22
13945.00900.0045.000.00
141226.00560.00570.0028.0068.40-0.40
15998.00780.00218.40-0.40
161797.00719.00814.0035.95227.920.13
17887.00395.00369.0019.75103.32-0.07
182278.00449.00628.00862.0022.4575.36241.36-0.17
Original Data
Cell Formulas
RangeFormula
AA2:AA18AA2=F2-SUM(G2:Z2)



Partly solved for Calculation by macro.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1Data with Manual calculation>>>>>GrossABCDEFGHIJKLMNOPQRSTR/o
23090.00254.00719.00794.00845.006.356.3543.1443.1471.4671.46118.30118.30-0.50
31518.00140.00998.00198.003.503.5059.8859.8827.7227.72-0.20
41894.00483.00504.00619.0012.0812.0845.3645.3686.6686.66-0.19
51710.00214.00368.00838.005.355.3522.0822.08117.32117.320.50
61977.00701.00835.00259.0017.5317.5350.1050.1023.3123.310.13
71880.00537.00180.00833.0032.2232.2216.2016.20116.62116.62-0.08
81580.00715.00702.0017.8817.8863.1863.180.89
92307.00526.00409.00931.00155.0013.1513.1524.5424.5483.7983.7921.7021.70-0.36
10977.00828.0074.5274.52-0.04
11730.00103.00475.0018.54133.000.46
121222.00434.00684.0021.7082.080.22
13945.00900.0045.000.00
141226.00560.00570.0028.0068.40-0.40
15998.00780.00218.40-0.40
161797.00719.00814.0035.95227.920.13
17887.00395.00369.0019.75103.32-0.07
182278.00449.00628.00862.0022.4575.36241.36-0.17
19
20Grand Total27,016.003,033.003,866.004,198.003,488.003,457.001,882.00103.003,300.0075.8375.83231.96231.96377.82377.82488.32488.32172.85225.8418.54924.00-0.08
2175.83231.96377.82488.32172.85225.8418.54924.00
22--------
23
Data with Manual calculation
Cell Formulas
RangeFormula
AA2:AA18AA2=F2-SUM(G2:Z2)
F20:AA20F20=SUM(F2:F19)
G21G21=G20*2.5%
H21H21=H20*6%
I21I21=I20*9%
J21J21=J20*14%
K21K21=K20*5%
L21L21=L20*12%
M21M21=M20*18%
N21N21=N20*28%
G22G22=G21-O20
H22H22=H21-Q20
I22I22=I21-S20
J22:N22J22=J21-V20
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Macro shared by Glenn only for the calculation in row 21 and 22.
Sub GST_Match()
'
' GST Macro
' Press control + small letter g to run the calculation.
'
' Keyboard Shortcut: Ctrl+g

Application.Calculation = xlCalculationManual
ActiveCell.FormulaR1C1 = "=R[-1]C*2.5%"
For ifill = 1 To 8
ActiveCell.Offset(1, ifill - 1).FormulaR1C1 = "=R[-1]C-R[-2]C[" & Application.Min(ifill, 5) + 7 & "]"
Next
ActiveCell.Offset(0, 1).FormulaR1C1 = "=R[-1]C*6%"
ActiveCell.Offset(0, 2).FormulaR1C1 = "=R[-1]C*9%"
ActiveCell.Offset(0, 3).FormulaR1C1 = "=R[-1]C*14%"
ActiveCell.Offset(0, 4).FormulaR1C1 = "=R[-1]C*5%"
ActiveCell.Offset(0, 5).FormulaR1C1 = "=R[-1]C*12%"
ActiveCell.Offset(0, 6).FormulaR1C1 = "=R[-1]C*18%"
ActiveCell.Offset(0, 7).FormulaR1C1 = "=R[-1]C*28%"
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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