error code 424

marcel49

New Member
Joined
Jun 8, 2019
Messages
10
Hello I'm new to VBA and I've put the following code in the VBA editor which I've got from a tutorial:

Public Sub Mijneersteprogramma()

Range("B2").Select
ActiveCel.Value = InputBox("Enter Waarde")
Range("B3").Select
Actievcel.Value = InputBox("Enter Waarde")
Range("b4").Select
ActiveCel.Value = InputBox("Enter Waarde")
Range("b5").Select
Actievcel.Value = InputBox("Enter Waarde")
Range("B6").Select
ActiveCel.Value = InputBox("enter Waarde")
Range("b7").Select
ActiveCel.Formula = "sum(B2..B6)"
ActiveWorkbook.SaveAs Filename:="Mijneersteprogramma.xls"

End Sub

When I run the code I get:error code 424 need object.

I done the step by step debugger and after putting a value in the Inputbox and clicked on Ok the error code apears

What is going wrong

Thank you for the answer

Marcel
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi & welcome to MrExcel.
You have spelt ActiveCell wrongly, try it like
Code:
Range("B2").Value = InputBox("Enter Waarde")
Range("B3").Value = InputBox("Enter Waarde")
 
Upvote 0
Code:
Option Explicit

Public Sub Mijneersteprogramma()

Const myTEXT As String = "Enter Waarde"

Range("B2") = InputBox(myTEXT)
Range("B3") = InputBox(myTEXT)
Range("b4") = InputBox(myTEXT)
Range("b5") = InputBox(myTEXT)
Range("B6") = InputBox(myTEXT)

'// jiuk - Sum the range
Range("b7") = "sum(B2..B6)"

'// jiuk - Save the Excel Workbook

ActiveWorkbook.SaveAs Filename:="Mijneersteprogramma.xls"

End Sub
 
Upvote 0
Or
Code:
Sub marcel49()
   Dim i As Long
   
   For i = 2 To 6
      Range("B" & i).Value = InputBox("Enter Waarde")
   Next i
   Range("B7").Formula = "=sum(B2:B6)"
   ActiveWorkbook.SaveAs "Mijneersteprogramma.xls", 56
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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