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

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
616
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:

Some videos you may like

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
are there any hidden sheets in active workbook?

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

Watch MrExcel Video

Forum statistics

Threads
1,122,798
Messages
5,598,112
Members
414,214
Latest member
marketingnumbersguy

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