Form info to different spreadsheet

  • Thread starter Thread starter Glenn
  • Start date Start date
G

Glenn

I have two spreadsheet's. Test1.xls which is on my C:
Drive and another spreadsheet Test2.xls which is on my H:
Drive both spreadsheets are in a file called temp.
The spreadsheet on my C: Drive contains a user form that
the user completes and then clicks on a button. I want
that information to be put on the spreadsheet on my H:\
drive.

For example I have a field on the form that the user
inserts the date (txtdate) when they click on a macro I
want it to take the date off the user form and insert it
into cell A2 on spreadsheet H:\temp\test2.xls.

I have asked before but nothing seems to work........
 
Hi Glenn,

Didn't test it, but it must work :

You supposed to have a "Save" button on the form. Put this code in its
Click event :

Dim wbHDrive as Workbook

If Me.txtdate.value<>"" And Not IsNull(Me.txtdate) then
Application.ScreenUpdating = False
set wbHDrive = Workbooks.Open("H:\temp\test2.xls")
With wbHDrive
..ActiveSheet.Range("A2") = Me.txtdate.Value
..Close True
end with
Application.ScreenUpdating = True
end if
 
Glenn,

Straight off the top, in the C: file userform code

Workbooks.Open Filename:="H:\temp\test2.xls"
With Activeworkbook
.Worksheets("Sheet1").Range("A2").Value = txtDate.Text
.Save
.Close
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top