| |
You are here: Experts > Computing/Technology > Basic > Visual Basic > Excel Macros
Expert: Richard Rost
Date: 8/17/2008
Subject: Excel Macros
Question The following macro gives me the error - Invalid use of property & takes me to first .Value line
Public Sub myfirstprogram()
Range("b2").Select
ActiveCell.Value -InputBox("Enter Value")
Range("b3").Select
ActiveCell.Value -InputBox("Enter Value")
Range("b4").Select
ActiveCell.Value -InputBox("Enter Value")
Range("b5").Select
ActiveCell.Value -InputBox("Enter Value")
Range("b6").Select
ActiveCell.Value -InputBox("Enter Value")
Range("b7").Select
ActiveCell.Formula -"-sum(b2..b6)"
End Sub
please tell me why i am getting this error & how to solve this problem.
Answer You don't have a properly formed statement. Plus, your InputBox is returning a STRING value. You can try converting it to an integer:
ActiveCell.Value = ActiveCell.Value-CInt(InputBox("Enter Value"))
I haven't tested this, but let me know if you have any other questions or comments.
Also, be sure to visit my FREE Tips & Tricks Page at http://www.599cd.com/tips?key=AllExperts
Cordially,
Richard Rost
599CD Computer Training
http://www.599cd.com
P.S. Try one of my FREE tutorials at http://www.599cd.com/VB?key=AllExperts
P.P.S. I volunteer my time at AllExperts to help people, and I get a LOT of questions, so I can't take an hour to answer each question. If you need more DETAILED HELP, come to my TechHelp web site at http://www.599cd.com/TechHelp/AllExperts and I'll take as much time as you need to answer your question.
View Follow-Ups
Add to this Answer
Ask a Question
|
|