How do I change the range in this code.

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
'for' Loop @Fluff need your help to edit this..
This code was shared by Fluff last year which worked correctly in the previous project. At first the data extracted was filled in around 600 rows but when the value of the amount to be extracted has increased, it is not possible to get the data in 600 rows. Hence the formulas in rows after the 600th row have been shifted to the top so that I can get unlimited rows to fill the data.
If the number of rows is avoided and changed to unlimited rows it will be really helpful in future.
I am trying this code by changing the range in the code by editing it. But I am getting a run time error 1004 at this line. Can someone please help me to correct it.? I want to add this code at the end of the existing code.
Rich (BB code):
         Cells(2000, .Offset(, -14).Column).End(xlUp).Offset(1).Resize(2).Value = .Offset(.Count - 2).Resize(2).Value
Link to the file is below
Shift amounts.xlsm
 
Last edited:
Ok, give me a few to look at your most recent file. Your most most recent file works right?
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I guess not. :(

The 'Get Total' button produces an error.
 
Upvote 0
I forgot to include the clear the Total sheet data in the Clear old Data macro.
Rich (BB code):
Sheets("Total").Select
    Range("A2:E2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.ClearContents
    Range("A2").Select
One more chance of error. The CR sheet may or may not have data at times. So when the code is combining the data of Daily and CR you need to add an if condition. If there is data in CR sheet then combine else display only the data in Daily sheet.
I know it is past your bed time. Let us continue this tonight. I too have got to go to office now. See you tonight.
 
Upvote 0
Still get error.

Please make sure your code works before you submit it for further corrections.
 
Upvote 0
Once you have used the clear old data, you will have to fill data in the CR sheet manually, at least one entry for the code to work correctly the next time else it will display everything wrong. Check the difference in cell G2 of the total sheet. If it is a small amount then it has worked correctly. That is the only way to check if the data is extracted successfully.
 
Upvote 0
Like I said, when you get a testable script, let us know.
 
Upvote 0
Untitled.png

Each time you use the clear button, just add 2 lines in the CR sheet like this. The code will display the result correctly. That is why I told you to add an if statement in the code. If CR cell A2 is blank then display Daily sheet data only in the total sheet else combine both the data.
 
Upvote 0
Still get the same error in the sort section of your code.
 
Upvote 0

Forum statistics

Threads
1,216,093
Messages
6,128,784
Members
449,468
Latest member
AGreen17

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