Help With Existing Code

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,486
Office Version
  1. 365
Platform
  1. Windows
I have been using this code below for some time and works great. I have now upgraded to 365 and I get an Compile error: Can't find project or library and points to mySource = (3rd row down)

What can be done please?

Code:
Sub CopyAndInsertRow()
'Copies selected rows and inserts amount you want entered in input box, then sorts by column C.
    Set mySource = Selection.EntireRow
mySource.Copy
selectedrowscount = mySource.Rows.Count
Dim x As Long, y As Long
x = mySource.Row
Dim t
t = InputBox("Enter Number Of Times Selected Row(s) To Be Copied.", "Number of Copies", 1)
If t = 0 Or t = "" Then Exit Sub
y = x + t * selectedrowscount - 1
Rows(x & ":" & y).Insert Shift:=xlDown
With ActiveSheet.Sort
    .SortFields.Clear
    .SortFields.Add Key:=Range("C1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    .SetRange Rows(x & ":" & y + selectedrowscount)
    .Header = xlNo
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With
Application.CutCopyMode = False
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,049
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
If you click Tools - References and scroll through them do any have missing alongside them?
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,486
Office Version
  1. 365
Platform
  1. Windows
If you click Tools - References and scroll through them do any have missing alongside them?
There was yes so I unticked and seems to work. Thanks so much.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,049
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
You're welcome
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,486
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

You're welcome
Spoke to soon. Closed and reopened and its doing it again. How do I get rid as its looking for an add-in that I had to rename.
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,486
Office Version
  1. 365
Platform
  1. Windows
Sorted, didn't realize I had to save changes to PWB.
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,486
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Just one thing, all macros created in old office versions should work in 365?
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,049
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
all macros created in old office versions should work in 365?

Most, there are a few exceptions but if your macro's were working in a version later than 2007 then you shouldn't have any issues with 365.
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,486
Office Version
  1. 365
Platform
  1. Windows
Most, there are a few exceptions but if your macro's were working in a version later than 2007 then you shouldn't have any issues with 365.
i have noticed that they take a lot longer to run in 365?
 

Watch MrExcel Video

Forum statistics

Threads
1,129,521
Messages
5,636,812
Members
416,942
Latest member
kitkat22

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
Top