VBA Range.copy does nothing - clipboard issues?

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
790
Office Version
  1. 365
Platform
  1. Windows
Hi all, got some super simple code here that's not working:

VBA Code:
est.Activate
LastrowEst = est.Cells(Rows.Count, "B").End(xlUp).Row

Range("C12:C" & LastrowEst).Copy

When I execute the copy command, nothing happens - there's no bounding box around the range in the est sheet. I've tested on single ranges.

Manual copies work and I get the dashed line on the copied range.

Can anyone help with this? Thank you.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Which module is the code in?
 
Upvote 0
Which module is the code in?
It's in a Worksheet_Activate module:

VBA Code:
Private Sub Worksheet_Activate()

'End Sub

Dim wb As Workbook
Dim ios As Worksheet, est As Worksheet, temp As Worksheet
Dim LastrowEst As Long, LastrowTemp As Long
Dim desc As String, CBS As String
Dim cost As Double

Set wb = ActiveWorkbook
Set ios = Sheets("Internal Only Summary")
Set est = Sheets("Estimate")

Application.ScreenUpdating = False
Application.EnableEvents = False

If ios.Range("CompletedEstimate") = "yes" Then
Exit Sub
End If

' Delete Temp sheet if one exists
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Temp").Delete
Application.DisplayAlerts = True
On Error GoTo 0

' Test if temp sheet exists
On Error Resume Next
Set temp = Worksheets("Temp")
On Error GoTo 0
' If sheet doesn't exist create
If temp Is Nothing Then
    Set temp = wb.Sheets.Add
    temp.Name = "Temp"
End If

est.Activate
LastrowEst = est.Cells(Rows.Count, "B").End(xlUp).Row

Range("C12:C" & LastrowEst).Copy
 
Upvote 0
That's what I figured. ;) Your Range property refers to the sheet with the code in it, not the active sheet. You should use est.Range(...) instead.
 
Upvote 0
That's what I figured. ;) Your Range property refers to the sheet with the code in it, not the active sheet. You should use est.Range(...) instead.
O Rory, you are so wise.

I'll amend that, thanks chum.

Rory to the rescue.

AGAIN
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,020
Members
449,203
Latest member
tungnmqn90

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