Click here to Skip to main content
15,885,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am learning VBA macros from the available videos over internet.When i am trying to execute the program,this particular statement is throwing the error -- "Range("A2").End(xlDown).Offset(1, 0).Value = Film_Name".But in the video is executed properly.Please help me with the issue

Sub generic()
Dim Film_Name As String
Dim Film_Date As Date
Dim Film_length As Integer

Film_Name = InputBox("Enter a film name")
Film_Date = InputBox("Enter a Date")
Film_length=Inputbox("Please enter the length of the film")
Range("A2").End(xlDown).Offset(1, 0).Value = Film_Name
Range("A2").End(xlDown).Offset(0, 1).Value = Film_Date
Range("A2").End(xlDown).Offset(0, 2).Value = Film_length

End Sub

What I have tried:

I have no clue what is wrong with the statement.Syntax is same as showed in the video.
Posted
Updated 2-Feb-18 23:09pm

1 solution

You need some data in the first column so that when it looks down for the first free cell beyond A2 it will find something. Just add a few random words to cells A1, A2, A3, A4, and it should work.
 
Share this answer
 
Comments
Member 13658733 3-Feb-18 6:05am    
Thanks Richard but I found 1 more solution to it.
Sheet1.Range("a65000").end(xlup).select

This one is working fine but i am still interested to know why the previous code didn't work.

PS: The column already has values as u suggested.
Richard MacCutchan 3-Feb-18 6:32am    
So Excel has to go down to row 65,000 and count up for each row above until it finds the first empty one. That is just a waste of electrons. Check what is in Column A starting at row 2, to see why the original code is not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900