Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Data Entry Form

You (or your code) will have to open the history workbook first.

If you open it before your code runs, you can change this line:

Set historyWks = Worksheets("Data")
to
Set historyWks = workbooks("History.xls").Worksheets("Data")

If you want the code to open it, you could use:

Dim HistWkbk as workbook 'near the other declarations
....

Then this line:
Set historyWks = Worksheets("Data")

Gets replaced with this bunch of code:

'check to see if it's open first
set histwkbk = nothing
on error resume next
set histwkbk = workbooks("history.xls") 'don't include the path
on error goto 0

if histwkbk is nothing then
'not open yet, so try to open it
on error resume next
'include the complete path
set histwkbk = workbooks.open(filename:="C:\path\path\history.xls "
on error goto 0

if histwkbk is nothing then
msgbox "Can't find the history workbook"
exit sub
end if
end if

'try to find that history worksheet
set historywks = nothing
on error resume next
set historywks = histwkbk.worksheets("Data")
on error goto 0

if historywks is nothing then
msgbox "Found the workbook, but not the worksheet!
exit sub
end if

''''

(Untested, uncompiled. Watch for typos!)

Chris wrote:

I have a data entry Form in excel 2007 that I created in vba. I was wondering
if instead of putting the data in the next sheet if it is possible to have it
put it into a workbook on a network. Here is my code.
Thanks!

Option Explicit

Sub GoInventory()
On Error Resume Next
Worksheets("Data").Activate
End Sub

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet

Dim nextRow As Long
Dim oCol As Long

Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D5,D6,D7,D8,D9,D10"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")

With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks

oCol = 1
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub

Sub GoInput()
On Error Resume Next
Worksheets("Input").Activate
End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Entry Form Brian T Excel Discussion (Misc queries) 8 March 5th 07 02:23 PM
Data entry form [email protected] Excel Programming 1 March 24th 06 08:50 PM
Data Entry form P.Jaimal Excel Programming 0 November 26th 05 05:32 PM
Data Entry Form (similar to default Excel DataForm) tonydm Excel Programming 0 October 11th 05 07:59 PM
Help with data entry form please Devon T. Sowell Excel Programming 4 February 1st 04 04:28 PM


All times are GMT +1. The time now is 09:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"