Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have been asked how to save data entered into a form on
an Excel worksheet into another workbook and to clear the form ready for re-use. Does anyone have any recommendations on the best way to do this. I only have Excel to work with. Many thanks for any help! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
With both workbooks open, maybe this'll work:
Option Explicit Sub testme01() Dim toWks As Worksheet Dim formWks As Worksheet Dim NextRow As Long Dim iCtr As Long Dim beforeAddress As Variant Dim afterCol As Variant Set formWks = Workbooks("book1.xls").Worksheets("form") Set toWks = Workbooks("book2.xls").Worksheets("HistoryLog") beforeAddress = Array("C6", "C7", "C8", "d9", "f10", "g11", "h12", "j13") afterCol = Array("c", "d", "e", "f", "g", "h", "i", "j") If UBound(afterCol) < UBound(beforeAddress) Then MsgBox "Error in before layout!" Exit Sub End If With toWks NextRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1 With .Cells(NextRow, "A") .Value = Now .NumberFormat = "mm/dd/yyyy hh:mm:ss" End With .Cells(NextRow, "B").Value = Application.UserName For iCtr = LBound(beforeAddress) To UBound(beforeAddress) 'move 'em in .Cells(NextRow, afterCol(iCtr)).Value _ = formWks.Range(beforeAddress(iCtr)).Value formWks.Range(beforeAddress(iCtr)).ClearContents Next iCtr End With End Sub Adjust the names of the workbooks & worksheets. And fix the cells that get copied over and the columns that they get saved into. Frances wrote: I have been asked how to save data entered into a form on an Excel worksheet into another workbook and to clear the form ready for re-use. Does anyone have any recommendations on the best way to do this. I only have Excel to work with. Many thanks for any help! -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how can i fill in information once and use it for several forms | Excel Discussion (Misc queries) | |||
Slow saving when adding VBA forms | Excel Discussion (Misc queries) | |||
Forms, Dropdowns, and Automated Information | Excel Discussion (Misc queries) | |||
saving and loading contents of user forms | Excel Discussion (Misc queries) | |||
Clearing entered information | Excel Discussion (Misc queries) |