Home > Software engineering >  VBA to sheet name specified cell name
VBA to sheet name specified cell name

Time:11-13

Could you tell me how to use VBA in Excel E1 batch operation makes the cell's name is the name of the sheet? How to write code?
Small white consult !!!!! Thank you thank you!

CodePudding user response:

 Sub Macro1 () 
For Each Sheet Sheets In
If the Trim (Sheet. Cells (5, 1). The Text & lt;> "") Then
Sheet. Name=Sheet. The Cells (5, 1). The Text
End the If
Next
End Sub

CodePudding user response:

Trim the sentence the position of the bracket is a bit wrong, use the following

 Sub Macro1 () 
For Each Sheet Sheets In
If the Trim (Sheet. Cells (5, 1). The Text) & lt;> "" Then
Sheet. Name=Trim (Sheet. Cells (5, 1). The Text)
End the If
Next
End Sub

CodePudding user response:

refer to the second floor fzyj_lord response:
trim that the position of the bracket is a bit wrong, use the following

 Sub Macro1 () 
For Each Sheet Sheets In
If the Trim (Sheet. Cells (5, 1). The Text) & lt;> "" Then
Sheet. Name=Trim (Sheet. Cells (5, 1). The Text)
End the If
Next
End Sub

Ok, I will try, thank you thank you

CodePudding user response:

refer to the second floor response:
trim that the position of the bracket is a bit wrong, use the following

 Sub Macro1 () 
For Each Sheet Sheets In
If the Trim (Sheet. Cells (5, 1). The Text) & lt;> "" Then
Sheet. Name=Trim (Sheet. Cells (5, 1). The Text)
End the If
Next
End Sub

1. You this is A5 cell is not E1 cell;
2. You are assigned to the cell contents table name, not the table name assigned to the cell;

CodePudding user response:

reference 4 floor milaoshu1020 response:
Quote: refer to the second floor response:

Trim the sentence the position of the bracket is a bit wrong, use the following

 Sub Macro1 () 
For Each Sheet Sheets In
If the Trim (Sheet. Cells (5, 1). The Text) & lt;> "" Then
Sheet. Name=Trim (Sheet. Cells (5, 1). The Text)
End the If
Next
End Sub

1. You this is A5 cell is not E1 cell;
2. You are assigned to the cell contents table name, not the table name assigned to the cell;


Oh, see the worry, wrong, sorry, sorry

CodePudding user response:

 Sub Macro1 () 
For Each Sheet Sheets In
Sheet. Cells (1, 5)=Sheet. The Name
Next
End Sub

CodePudding user response:

That is if the specified file name of the sheet? Folder is another sheet of the workbook in the cell?
  •  Tags:  
  • VBA
  • Related