macro for variable no. of rows

rakeshshethia

New Member
Joined
Jan 31, 2014
Messages
37
HI.


I am new to macros. Let me explain what I want the macros to do. The range is from column A to column O. No. of Rows are variable for different sheets downloaded from the system. As in, if the last row is at no. 30, all the columns would have data in last row at no. 30, but it is not necessarily 30 in all the excel files.


Part 1
I want to delete column B. Out of remaining columns, delete columns H to M. Now, the data in column G and H is in numbers. Column G is "Amount" and Column H is "Commission". I want the sum at the end of the respective columns.


Part 2
Later, I want the difference between the sums of Column G and Column H after 4 rows from the last row and in Column B. The adjacent cell in column A should have the text "Debit".

Part 2A
This is if I want the sum of Column G and H, however the number at fourth row from the last column is equal to the sum of G (and not the diff. as in Part 2)


I need macros for three different parts as it can be Part 1 AND either Part 2 or Part 2A in the sheet.


Please help.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,226,217
Messages
6,189,687
Members
453,563
Latest member
Aswathimsanil

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