Macro Issue

HiltonHappy

New Member
Joined
Jun 27, 2024
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello, I hope you're all well. I've recently started using macros to automate certain processes at work, however I'm running into an issue with one specific thing that I unfortunately do not know how to resolve, the software that we use at work ends every report with the following-

breakfast4.png


The position of this is dependent on the length of the report and the number will also change accordingly, and what I am struggling with is finding a way to find it and delete all of it- most importantly the number which is found in column C as that is where our software outputs numbers. Any input would be extremely helpful, and I'm sure that the solution is in all likelihood much simpler than I would have thought.
Thank you!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
It looks like that the number is in Column D, not Column C
Does it say "UNFUFILLED" instead of "UNFULFILLED"? '<---- Check spelling
If so, there are multiple possibilities
Try on a copy of your original.
Code:
Sub Delete_Number_A()
Cells(Rows.Count, 4).End(xlUp).ClearContents
End Sub
Code:
Sub Delete_Number_B()
Cells(Rows.Count, 1).End(xlUp).Offset(-2, 3).ClearContents
End Sub
Code:
Sub Delete_Number_C()
Columns(1).Find("TOTAL UNFULFILLED REQUESTS:",,,1).Offset(, 3).    '<---- Check spelling
End Sub
For all of it
Code:
Sub Delete_All_A()
Columns(1).Find("TOTAL UNFULFILLED REQUESTS:",,,1).Resize(3, 4).ClearContents    '<---- Check spelling
End Sub
Code:
Sub Delete_All_B()
Cells(Rows.Count, 1).End(xlUp).Offset(-2).Resize(3, 4).ClearContents
End Sub
Code:
Sub Delete_All_C()
Columns(1).Find("END OF REPORT",,,1).Offset(-2).Resize(3, 4).ClearContents
End Sub
 
Upvote 1
Curiously enough, it does say unfufilled, not one of my coworkers had noticed that either. The only bit of uncertainty that I am having is where exactly that code should go- currently the macro looks like this.
Screenshot 2024-06-28 061618.png

This is one of the macros for one of the smaller reports, as an example should it go towards the beginning or the end? I ask as when I attempt to paste excel notifies me that my project will be reset and the command stops working, I suspect this is because of the 'End Sub' at the end of each command set?
Thank you!
 
Upvote 0
Recorded macros should be cleaned up if possible at all.
The selecting makes code slow and jittery.

Try with putting just the one middle line of whichever macro you want to use before the "End Sub"
The last part of your code would look like so.
Code:
Columns("A:A").EntireColumn.AutoFit
Cells(Rows.Count, 1).End(xlUp).Offset(-2).Resize(3, 4).ClearContents
End Sub

Remember, the code snippets are based on what you show in your first post.
"TOTAL UNFUFILLED REQUESTS:" and "END OF REPORT" are in Column A and the number 6 is in Column D
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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