Deleting cells does not completely delete data

Brutusar

Board Regular
Joined
Nov 23, 2019
Messages
166
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a workbook with 13 sheets. 3 of these are input sheets where data is entered manually (Or pasted). 1 is an output sheet that is holding the final result, and the rest are sheets holding data and VBA code for different processes that run to process data from input to output. When a process is finished the output is saved to another file, and a new process is started after deleting all data.

However, after deleting the manually entered data, it seems like it is not "really" deleted.

For instance, Sheet A holds x number of rows. The number of rows is counted and used as a variable in the VBA code. If this process run thru, the input in Sheet A is deleted, and new data is entered in (a different number of rows), this number is sometimes added on top of the previous number.

So if the first run had 20 rows, and the second 30, the variable holding this value shows 50, not 30, causing an error in the end. This may also happen if the workbook has been saved and closed between the first and second run.

Does anyone have an idea what may cause this?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
How is the variable scoped. Is it in sheet code or module code. Is it public or private? Do you have more than 1 workbook open... I don't understand how a variable could maintain it's value after the workbook is closed? Why not just ensure that the variable is set to zero at the start of the routine? HTH. Dave
 
Upvote 0
There is not sufficient info to answer this, but if the rows are counted at each run, then it is evident that the previous rows are not deleted correctly or the number of rows is written to a cell somewhere in the 13 sheets and not set to zero prior to saving the workbook/running the next process.
 
Upvote 0
OK, thanks, guys! I will brew a very strong coffee and sit down with a magnifying glass to try to figure this out :)
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,448
Members
448,966
Latest member
DannyC96

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