This does NOT leave a Pastable Range

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
232
Office Version
  1. 365
Platform
  1. Windows
The Code
Code:
Sub Data_CutCopy_Sub(Sheet_Spec, Rng, Start_Row, Mode_ As CutCopy_Mode)
    ' Common code for Cut/Copy.
    ' 4/30/148 Created. WML
    
    Prog = "Data_CutCopy_Sub"
    
    Call Sheet_Arg(Sheet_Spec, SHEET, Sheet_Name)
    Rng = [COLOR=#574123]Range("C1293:D1293")  ' <-- To make explicit what "Rng" is.[/COLOR]
                      
    With SHEET
        Select Case Mode_
            Case ccm_Copy
                Range(Rng).Select   ' <-- This is the code that executes when I run this macro.
                Selection.Copy
            Case ccm_Cut
                .Selection Cut
        End Select
    End With


End Sub ' Data_CutCopy
I want it to leave the selected range with the dotted line around it that means that it can be pasted later. This code does select it but does not leave as pasteable (with the dotted line around it).

This code does what I want:
Code:
    Range("C1293:D1293").Select
    Selection.Copy
Is the problem the "With SHEET"?

Thanks for your help, Mac
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
After Sheet_Arg is finished running, the variables could be reset to nothing, depending on how and where you have them declared, so that could be the problem.

If you post all relevant code, including anything called by this code, someone can probably help you out.
 
Upvote 0
You need to define Range as a Range object and use Set. However the Select statement is completely unnecessary.

I'm not sure how you're getting the value for SHEET, but if you are going to use With you need a . before the properties.

For example:

Code:
Sub test()
Dim Rng As Range
Dim Sheet As Worksheet
Set Sheet = Worksheets("Sheet2")
With Sheet
    Set Rng = .Range("C1293:D1293")
    Rng.Copy
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

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