Why would my macro be repeating itself?

joshman108

Active Member
Joined
Jul 6, 2016
Messages
310
I have a macro which loops through most of the dozens of sheets in the workbook and checks to see if the selected range of cells is wider than a single column and contains 0 blank cells. If these are true it copies the selection to the "uploader" tab. This macro had been working properly for about 7 months for myself and my coworkers. Suddenly, it stopped working for me like 2 weeks ago. Now, once it reaches the end of the macro it just loops through again. I know this because I can see things are being copied over twice.

The basic code is as follows:

Code:
If Worksheets("GumGum").Visible = True Then
Worksheets("GumGum").Activate
count = WorksheetFunction.CountBlank(Selection.Cells)
lngcols = Selection.Columns.count
lngrows = Selection.Rows.count
If lngcols > 1 And count = 0 Then
    Selection.Copy
    
    Worksheets("UPLOADER").Activate
    ActiveCell.PasteSpecial Paste:=xlPasteValues


        If lngrows = 1 Then
        ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
        Else
        Selection.End(xlDown).Select
        ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
        End If
Else
End If
Else
End If

This basic section is replicated for all of the tabs which are potentially being copied.

Here's the thing. There is ONE SPECIFIC copy of this code for one specific tab which, when I delete it from the macro and re-run, it tends to run perfectly fine. But this is not always the case and furthermore, when I save the workbook and re open it with that specific section still being removed, the macro STILL loops through twice. I tried removing other un-used chunks of code (commented sections/old tabs etc) and after each attempt the macro seems to work... until I close and reopen. I also tried re-writing some sections which also appeared to fix it.. UNTIL I saved and reopened at which point it still loops through twice. So all of my attempts appear to be red-hearings and not really the root of the problem. And in the midst of all of this my coworkers are still using the macro without any problems.

I am so baffled. Does anyone have any insight?
I'm on the most recent version of excel for mac.

Thanks
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
if it hits the end sub at the end of the macro, then it is being called again from something else
 
Upvote 0
Hmm. Thanks for the suggestion. I'm just not sure what it would be. I entirely uninstalled and reinstalled office on my computer and that did nothing. I'm beside myself.
 
Upvote 0
Can you post the full code including the declaration line at the start?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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