Macro Suddenly Stopped Working

JohnTravolski

New Member
Joined
Nov 25, 2015
Messages
45
Office Version
  1. 2019
Platform
  1. Windows
I have a macro to copy the selected cells as a comma delimited string to the clipboard:

VBA Code:
Sub CopySelectedAsCommaDelimittedString()

    If Not Selection Is Nothing Then
   
        Dim rtn As String: rtn = vbNullString
        Dim r As Range
        For Each r In Selection.Rows
            Dim a: a = Application.Transpose(Application.Transpose(r))
            rtn = rtn & Strings.Join(a, ",")
        Next
   
        If rtn <> vbNullString Then
   
            Dim clip As MSForms.DataObject: Set clip = New MSForms.DataObject
            clip.SetText rtn
            clip.PutInClipboard
   
        End If
    End If
End Sub

It used to work fine. However, within the past couple of weeks, it simply stopped working. Nothing is copied to the clipboard anymore when I run it with cells selected. I have no idea what changed. Does anybody know why this might be? Is there something in Excel I should check is enabled? Any advice as to how to potentially fix this?

I have checked and MSForms is enabled:
1601069760938.png
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Turns out it was because file explorer was open. In Windows 10, with file explorer open, the code doesn't work. It works as soon as it is closed. To fix that, I had to use the solution here:
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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