Comparing 2 bits of code

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Is there a way to compare 2 VBA Projects in terms of code?

Whilst creating my project I have regularly been saving different versions, to ensure I could go back to them if things went wrong. What I hadn't been paying attention to however was the size of the files.

Having now finished I've seen that the file is quite large, and I don't know the exact cause of this.

I have 2 files saved 20 mins apart where there is a 24,000 kb change in file size.

Having looked at them I can't see an obvious change, so was wondering if there was any way I could compare the 2 in terms of code without having to manually scroll through everything until I find the difference?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hmmm the only way I know of getting the lines in your code for comparison is using something like:

Application.VBE.VBProjects.Item(ii).VBComponents.item(jj).CodeModule.Lines(1,nn)

Where:
ii is your Project
jj is your the object in your project
nn is the last line you want to output (this can also be captured from ...CodeModule.CountOfLines)

It will output a string (I think), with what your module contains. You could then do a compare on that?
 
Upvote 0
Thanks for your help,

found the problem, and it wasn't in my code, but it's still good to have that to refer to in case I need it in future.

The actual problem is that I have a sheet with over 100,000 rows in it. In my latest save this cells are all hidden, but excel is obviously still loading them initially.

How do I delete these rows?
 
Upvote 0
100,000 rows of data that you want to clear before it runs your other code?

If you don't need the headers then:

Sheet1.cells.clear

Where sheet1 is your sheet's codename.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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