Ilounah Posted July 13, 2018 Share Posted July 13, 2018 Hello Guys, Can you help me tweak my vba code I have 3 forms that will fill up my vlookup formula can you lead me how to fill up this in one click after item was selected on Dialog Box? UserForm1.TextBox1.Value = D:\BOOTDRV\AlohaTS\RptExport\ProductMix07012018.csv ( I need to remove filename, just the pathway D:\BOOTDRV\AlohaTS\RptExport\ ) UserForm2.TextBox2.Value = ProductMix07012018.csv (Get the filename only without the pathway) UserForm2.TextBox3.Value = ProductMix07012018 (Remove extension) Thank You very much. I'll be using this on our Inventory Report Sub Calculate() Dim objDialog As Object Set objDialog = Application.FileDialog(3) With objDialog .InitialFileName = UserForm1.TextBox1.Value .AllowMultiSelect = False .Show If .SelectedItems.Count = 0 Then MsgBox "No file selected." Else UserForm1.TextBox2.Value = Dir(.SelectedItems(1)) UserForm1.TextBox3.Value = Replace(UserForm1.TextBox2.Text, ".csv", "") End If End With Set objDialog = Nothing End Sub Link to comment Share on other sites More sharing options...
water Posted July 13, 2018 Share Posted July 13, 2018 Function _PathSplit should do what you want. Ilounah 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Ilounah Posted July 13, 2018 Author Share Posted July 13, 2018 Hello @water, I think _PathSplit is for Autoit what if I used vba code? Link to comment Share on other sites More sharing options...
water Posted July 13, 2018 Share Posted July 13, 2018 I see. Maybe this article sheds some light onto the subject: https://stackoverflow.com/questions/1743328/how-to-extract-file-name-from-path My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Ilounah Posted July 14, 2018 Author Share Posted July 14, 2018 (edited) Thank You Again Sir @water, Data for my vlookup is now set Sub CalculatePmix() Dim filename As String With Application.FileDialog(3) .AllowMultiSelect = False .Show If .SelectedItems.Count = 0 Then MsgBox "No file selected." Else filename = .SelectedItems(1) UserForm1.TextBox2.Value = Dir(.SelectedItems(1)) UserForm1.TextBox3.Value = Replace(UserForm1.TextBox2.Text, ".csv", "") UserForm1.TextBox4.Value = Left(filename, InStrRev(filename, "\")) Application.ScreenUpdating = False Workbooks.Open (filename) UserForm1.TextBox5.Value = Sheets(UserForm1.TextBox3.Value).Range("A5").Value Workbooks(UserForm1.TextBox2.Value).Close SaveChanges:=False Application.ScreenUpdating = True UserForm1.TextBox6.Value = Format(CDate(UserForm1.TextBox5.Text), "DD") End If End With End Sub Edited July 14, 2018 by Daniza Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now