Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
HELP: Populate form fields (intranet) from a workbook(network driv
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="john, post: 6419889"] Sam, Your data is stored in a workbook on network shared drive and you just need to “extract†data from it to populate your form? If correct, you could as a suggestion, just make a copy of the shared data and populate the existing worksheet your form currently extracts the data from. Code would look something like following - not tested but hopefully, may do what you want. Change sheet names and directory etc data as required. Sub GetSamsData() Dim DBFile As String Dim MyPassword As String Dim DestWB As Workbook Dim DestRng As Range Dim SourceWB As Workbook Dim SourceRng As Range MyPassword = "sam" DBFile = "I:\samsfiles\sams.xlsm" If Dir(DBFile) <> Empty Then Application.ScreenUpdating = False Set DestWB = ThisWorkbook Set SourceWB = Workbooks.Open(DBFile, ReadOnly:=True, Password:=MyPassword) Set SourceRng = SourceWB.Worksheets("Sheet1").UsedRange With DestWB.Sheets("Sheet1") .Cells.ClearContents Set DestRng = .Range("A1") End With SourceRng.Copy DestRng.PasteSpecial xlPasteValues, , False, False SourceWB.Close False With Application .CutCopyMode = False .ScreenUpdating = True End With Else msg = MsgBox(DBFile & Chr(10) & "File Not Found", 16, "Error") End If End Sub call it from forms Initialize event like this: Private Sub UserForm_Initialize() GetSamsData End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
HELP: Populate form fields (intranet) from a workbook(network driv
Top