Hi,
i need some help. I want to create a userform that when you enter the sheet name in textbox1 all data in the userform will be added to the sheet i entered in textbox1.
thanks
Hi,
i need some help. I want to create a userform that when you enter the sheet name in textbox1 all data in the userform will be added to the sheet i entered in textbox1.
thanks
Re: Userform textbox to a specific sheet code
What I would do is create a function in the user form module.
Function DirectedWorksheet() as Worksheet
On Error Resume Next
Set DirectedWorksheet = ThisWorkbook.Sheets(Me.TextBox1.Text)
On Error Goto 0
End Function
Then, all of your write to sheet code could reference that function
Re: Userform textbox to a specific sheet code
If you want to use the form for multiple sheets then instead of a TextBox, which allows possible typos, use a ComboBox.
Select the required sheet, complete the inputs then click enter
Re: Userform textbox to a specific sheet code
Thank you everyone for the replies and sample format.
Now I have a good idea regarding my userform.
By the way can I still use the the textbox? other than combobox. Is there any conflict if I still use the textbox. Because my idea is i will connect that textbox1 in my excel sheet with vlookup so once i enter the number in excel sheet and open the userform it will be automatic copy in textbox1 and after that i will enter the other data to be encoded to specific sheet according to the textbox1. I hope you understand. Can I have a sample excel please for your assistance. Thank you.
Re: Userform textbox to a specific sheet code
You can use a TextBox but as I have said earlier it is not the way. Using a ComboBox is most efficient and can also be used to avoid using VLOOKUP in your code, which I never do.
Re: Userform textbox to a specific sheet code
Can I restrict other sheets so that it will not appear in the combobox?
Re: Userform textbox to a specific sheet code
Hi sir. Can i disable some of the sheets so that it will not appear in the combobox? Please help for the code.
Re: Userform textbox to a specific sheet code
You can load specific sheets to the combobox but attach an example workbook and say which sheets that you want to list
Re: Userform textbox to a specific sheet code
For example to the "add to different sheets excel" that you made for example the Data1 is the sheet that i dont want to appear in the combobox. What is the code for that. Thank you.
Re: Userform textbox to a specific sheet code
Change the Function to this
'-----------------------------------------------------------------------------
'Function to return an array of all worksheet names
'-----------------------------------------------------------------------------
Don’t have an account yet? Register yourself now and be a part of our community!