LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 187
Default change the name of a worksheet/update VBA code

I have a bond pricing template designed by someone else which I'm
automating.

I have a number of subs, such as the following:

Sub EnterFaceParValueOfBond()
Dim MyString As String
Dim MyString2 As String
MyString = Application.InputBox("Enter face/par value of bond")
'Queries the user to enter the face/par value of the bond
Worksheets("PRICE OF BOND").Range("b2") = MyString
'Inserts the value entered by the user in cell B2
If Worksheets("PRICE OF BOND").Range("b2") = False Then
MsgBox ("Caution! Canceling Input sets the price of the bond
to $1,000.00!")
Else: Exit Sub
End If
MyString2 = 1000
Worksheets("PRICE OF BOND").Range("B2") = MyString2
End Sub

The worksheet name needs to be change to PriceOfBond (because Access
is pulling data from this worksheet, and it doesn't deal well with
spaces in names). If I leave the code as it appears above, I get a
"subscript out of range" error, presumably because PriceOfBond does
not agree with PRICE OF BOND in the above code.

So: is there a way to have Excel automatically update code if the name
of the worksheet changes? Or do I have to manually go into this code
and change the worksheet names?

Thanks....

 
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
VBA Code to Change the Tab Name Michael in Texas Excel Discussion (Misc queries) 1 March 28th 07 03:07 AM
VBA Code to Change the Tab Name Gary''s Student Excel Discussion (Misc queries) 0 March 28th 07 12:05 AM
How to update cell on change J.P. Excel Discussion (Misc queries) 5 July 11th 06 01:37 AM
How do I get one worksheet to update when others change? Bdubs Excel Worksheet Functions 1 March 21st 06 06:40 PM
change the code to be a formula Little pete Excel Discussion (Misc queries) 1 November 30th 05 07:29 PM


All times are GMT +1. The time now is 10:38 PM.

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"