UserForm VBA excel. Saving data depending on the parameters

Closed
gogazapr Posts 3 Registration date Friday June 18, 2021 Status Member Last seen February 7, 2022 - Feb 7, 2022 at 01:44 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Feb 8, 2022 at 11:54 AM
Hello,

I created a UserForm through Excel VBA with the data text input which contains dates (ex. 2015,2016 etc.) I need this data to be put into different worksheets upon saving depending on the input year. For example data with a 2015 year needs to go to a designated Sheet 2015, data with 2016 input needs to go into a separate sheet etc.
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Feb 8, 2022 at 11:54 AM
Hi Gogazapr,

When you use Textbox1 to input the year and want the value from Textbox2 to go to cell A1 of the sheet entered in Textbox1, the code line for the command button would be:
Sheets(TextBox1.Value).Range("A1").Value = TextBox2.Value


Best regards,
Trowa
0