rename worksheet

V

Vladimir

I have a workbook with worksheets. The first is a plan for a quoter and other
3 are
monthly reports. Each report sheet has 2 textboxes, one for month and one
for year.
Textboxes receive data from respective linked cells.
Both text boxes receive data from the linked cell which have formulas to
select a month and a Year.
I tried several codes which work perfectly when you enter the data directly
into the text boxes (or directly into the cell for the name of the worksheet
if you want to rename cell from the range). But when I tried to use formula
in the linked cell it stopped to work.
Could you please help me to have report tabs renamed automatically when
values of the linked cells (or text boxes) are changed by formula.
Thanks/Vladimir
 
J

JLGWhiz

For more accurate analysis and advice, post the relevant code or formulas
that are not working the way you expect them to.

:
 
V

Vladimir

Private Sub TextBox1_LostFocus()
On Error Resume Next
ActiveSheet.name = Me.TextBox1.Value & Me.TextBox2.Value
End Sub

Private Sub TextBox2_LostFocus()
On Error Resume Next
ActiveSheet.name = Me.TextBox1.Value & Me.TextBox2.Value
End Sub

When user entered new date in sheet 1, in each sheet 2, 3 & 4 two text
boxes (one for Month and 1 for Year) will change. I need that same time each
sheet 2, 3 & 4 to be renamed "Month & Year".
Text boxes in each sheet 2, 3, & 4 change from linked cells which change by
formula.
:), hope didn't make it too complicated.
 
J

JLGWhiz

If you put a formula in the linked cell, you destroy the link. You can,
however, put code behind the TextBox that puts the cell value of a formula in
the TextBox. For example:

Private Sub TextBox1_Enter()
Me.TextBox1.Value = Range("A1").Value
End Sub

Private Sub TextBox1_Exit()
Me.TextBox1.Value = ""
End Sub

I don't believe the TextBox uses the GotFocus property.
 
V

Vladimir

Dear "JLGWhiz",
Thanks for your reply. To be honest I'm absolute 0 in the VBA and the only
thing I'm able to do is to paste your code in the code of the worksheet and
it does not change the sheet name as I need.
If possible could you give me complete code for my purpose, please .
Vladimir
wrote:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top