Excel/vba help

woods2007

Board Regular
Joined
Aug 29, 2007
Messages
57
Hi,

In Excel 2010 I have a macro button on my Quick access tool bar to run the below code:


Sub DataPrep()

Dim finalrow As Long

finalrow = Cells(Rows.Count, 1).End(xlUp).Row

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
ActiveCell.FormulaR1C1 = "DataRef"
Range("A2").Select
ActiveWindow.SplitRow = 1
ActiveWindow.FreezePanes = True
Cells.Select
Cells.EntireColumn.AutoFit
Range("A2").Select
ActiveCell.FormulaR1C1 = "1"

Range("a2").AutoFill Destination:=Range(Cells(2, 1), Cells(finalrow, 1)), Type:=xlFillSeries


Rows("1:1").Font.Bold = True

'show finalrow

[a2].Select

Selection.End(xlDown).Select

'remove any blank workSheets

Dim Ws As Worksheet
For Each Ws In Worksheets
If WorksheetFunction.CountA(Ws.Cells) = 0 Then
Application.DisplayAlerts = False
Ws.Delete
Application.DisplayAlerts = True
End If
Next Ws

End Sub

However it won't run the code saying that the 'Macro is not available' but I can still run the macro if i go through 'view macros'

can anyone provide a solution?

Many thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I believe that the problem is that the button needs to specify the full path name to the macro, including the file it is located in.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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