VBA userform textbox to textfile and back

jam1531

New Member
Joined
Jan 5, 2015
Messages
29
Hello,
Stumped on this one. I have a userform with a textbox to input item number(s) and two option buttons "upload" and "retrieve". when the code is run I would like it to doe the following:

If optionbutton1.value = true then

I'd like it to take the item number(s) to be put into a textfile (C:\Users\jmckibb\Desktop\My Stuff\text.txt) and include the Environ("username") and today's date in three columns, for example:

[TABLE="width: 500"]
<tbody>[TR]
[TD]Item_Nbr[/TD]
[TD]UserID[/TD]
[TD]Date[/TD]
[/TR]
[TR]
[TD]123456789[/TD]
[TD]klj1001[/TD]
[TD]12/19/18[/TD]
[/TR]
</tbody>[/TABLE]
The catch is if the item number already exists on the sheet then the userID and name need to be replaced with the current Environ("username") and today's date. This way we always have the last to update but do not have duplicates.

Elseif optionbutton2.value = true then
a new workbook is created and the texfile is imported into sheet1 into columns 1, 2 and 3.

End if

Any help appreciated. Thanks!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top