When can a macro need to be in personal.xls vs. the input file?

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
705
Office Version
  1. 365
Platform
  1. Windows
The macro below works when it is in the file I'm running it on. When I put the macro in my personal.xls file it gives me error 400. When do I need to do to be able to include it in personal.xls so that I don't have to copy it over to my input file every time I run it?
---------
Code:
Sub Reformat()
 
'Eliminate multiple rows 
Dim WBO As Workbook
Dim WSO As Worksheet
Dim WBN As Workbook
Dim WSN As Worksheet
Dim LastRow As Long
Dim i As Long
 
Application.ScreenUpdating = False
 
Set WBO = ActiveWorkbook
Set WSO = WBO.ActiveSheet
Set WBN = Workbooks.Add(template:=xlWBATWorksheet)
Set WSN = WBN.Worksheets(1)
 
LastRow = WSO.Cells(Rows.Count, "A").End(xlUp).Row
 
NextRow = 2
For i = 2 To LastRow
If Application.CountIf(WSO.Range(WSO.Cells(2, "A"), WSO.Cells(i, "A")), WSO.Cells(i, "A")) = 1 Then
WSO.Cells(i, "A").Resize(1, 37).Copy Destination:=WSN.Cells(NextRow, "A")
WSO.Cells(i, "AM").Resize(Application.CountIf(WSO.Range(WSO.Cells(2, "A"), WSO.Cells(LastRow, "A")), WSO.Cells(i, "A")), 1).Copy
WSN.Cells(NextRow, "AM").PasteSpecial Transpose:=True
NextRow = NextRow + 1
End If
Next i
 
WSN.Cells(2, "A").Select
Workbooks(1).Activate
Application.CutCopyMode = False
Application.ScreenUpdating = True
 
End Sub
 
Last edited by a moderator:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
are there any hidden sheets in active workbook?

on which line of the code this error occurs?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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