Runtime error 438, excel doesn't support this property or method?

Mangolili

Board Regular
Joined
Jun 21, 2011
Messages
54
I was following a VBA tutorial and write the exact code in excel 2007. However, I got a Runtime error 438, excel doesn't support this property or method.

Anyone know why? Please let me know, thank you.



Option Explicit


Sub createWorkbook()

'DECLARE VARIABLES

Dim lngPref As Long, wkbNew As Workbook

Dim strPrefix As String, intsheets As Integer, i As Integer


'CAPTURE USER PREFERENCE

lngPref = Application.sheetsinNeWorkbook
strPrefix = InputBox("Please enter your prefix", "New workbook")
intsheets = InputBox("number of sheets required", "New workbook")

'CREATE WORKBOOK CONTAINING 4 SHEETS
Application.SheetsInNewWorkbook = intsheets
Set wkbNew = Application.Workbooks.Add


'NAME SHEETS IN NEW Workbook

For i = 1 To intsheets
wkbNew.Worksheets(i).Name = strPrefix & "" & i
Next

'RESTORE USER PREFEREMCE

Application.SheetsInNewWorkbook = lngPref
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Never mind, I found out that for one of the Application.SheetsInNewWorkbook, I left out a w before Workbook.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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