Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default InputBox value in formula problem

Can anyone tell me what the problem is with the following code?
Period = InputBox("Input invoice period, e.g. AUG-07", "Period")
Sheets("ANNUAL MASTER").Select
Range("D7").Select
ActiveCell.FormulaR1C1 = "=Spreadsheet!R[-5]C[-3] &"" """ & Period

When I run this in a Macro, I get a VB "Run-time error '1004':
Application-defined or object-defined error". It doesn't seem to like the "&
Period" portion at the end of the last line. If I take that piece out, it
works fine. The code seems to conform to the syntax that I have seen in many
other places, so I'm stumped.

Any help would be greatly appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default InputBox value in formula problem

you have issues with your & and your quotes... Give this a try...

Period = InputBox("Input invoice period, e.g. AUG-07", "Period")
Sheets("ANNUAL MASTER").Select
Range("D7").Formula = "=Spreadsheet!A2 & " & " " & Period

--
HTH...

Jim Thomlinson


"COV MarshallT" wrote:

Can anyone tell me what the problem is with the following code?
Period = InputBox("Input invoice period, e.g. AUG-07", "Period")
Sheets("ANNUAL MASTER").Select
Range("D7").Select
ActiveCell.FormulaR1C1 = "=Spreadsheet!R[-5]C[-3] &"" """ & Period

When I run this in a Macro, I get a VB "Run-time error '1004':
Application-defined or object-defined error". It doesn't seem to like the "&
Period" portion at the end of the last line. If I take that piece out, it
works fine. The code seems to conform to the syntax that I have seen in many
other places, so I'm stumped.

Any help would be greatly appreciated!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default InputBox value in formula problem

Thanks Jim, that did the trick! Thanks very much for your quick help!

"Jim Thomlinson" wrote:

you have issues with your & and your quotes... Give this a try...

Period = InputBox("Input invoice period, e.g. AUG-07", "Period")
Sheets("ANNUAL MASTER").Select
Range("D7").Formula = "=Spreadsheet!A2 & " & " " & Period

--
HTH...

Jim Thomlinson


"COV MarshallT" wrote:

Can anyone tell me what the problem is with the following code?
Period = InputBox("Input invoice period, e.g. AUG-07", "Period")
Sheets("ANNUAL MASTER").Select
Range("D7").Select
ActiveCell.FormulaR1C1 = "=Spreadsheet!R[-5]C[-3] &"" """ & Period

When I run this in a Macro, I get a VB "Run-time error '1004':
Application-defined or object-defined error". It doesn't seem to like the "&
Period" portion at the end of the last line. If I take that piece out, it
works fine. The code seems to conform to the syntax that I have seen in many
other places, so I'm stumped.

Any help would be greatly appreciated!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default InputBox value in formula problem

Can anyone tell me what the problem is with the following code?
Period = InputBox("Input invoice period, e.g. AUG-07", "Period")
Sheets("ANNUAL MASTER").Select
Range("D7").Select
ActiveCell.FormulaR1C1 = "=Spreadsheet!R[-5]C[-3] &"" """ & Period


Assuming "Spreadsheet" reference is correct, try it this way...

ActiveCell.FormulaR1C1 = "=Spreadsheet!R[-5]C[-3]&""" & " " & Period & """"

The other possibility is to modify the Period assignment line like this....

Period = " " & InputBox("Input invoice period, e.g. AUG-07", "Period")

and then use this for the last line...

ActiveCell.FormulaR1C1 = "=Spreadsheet!R[-5]C[-3]&""" & Period & """"

Rick
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed with Inputbox problem Gary''s Student Excel Programming 3 April 10th 07 03:31 PM
Help needed with Inputbox problem Norman Jones Excel Programming 3 April 10th 07 02:43 PM
Inputbox/Regression Problem Matt[_36_] Excel Programming 2 February 20th 06 08:15 PM
Inputbox/Regression Problem MattB[_3_] Excel Programming 0 February 17th 06 06:29 PM
Inputbox for Worksheet name - problem Stuart[_5_] Excel Programming 3 February 13th 04 07:02 PM


All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"