ok im still having a problem, this one may not be restricted to the validation.
im getting an "Application Defined or Object Defined Error" error at line this line
historyWks.Cells(nextRow, oCol).Value = myCell.Value
So basically, the code is supposed to get the data in the MyCopy cells on the input sheet, then copy the contents to the salesdata sheet. on the sales data sheet, its supposed to start inputting the contents that were copied into cell D3, contiguously within that sheet. so it would just paste into cell D3,E3,F3,H3 Etc etc.I think i may have some syntax errors. Can anyone assist??
again, a link to the original sample code i got online is at:
http://www.contextures.com/xlForm02.html#edit
Option Explicit
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 = "D7,D9,D11,D13,I7,I9,I11,I13,N7,N9,N11,N13"
Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("SalesData")
With historyWks
nextRow = .Cells(.Rows.Count, "3,2").End(xlUp).Offset(2, 1).Row
End With
With inputWks
Set myRng = .Range(myCopy)
' If myRng.Count <> Application.WorksheetFunction.CountA(myRng) Then
If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox " Please fill out all the cells "
Exit Sub
End If
End With
With historyWks
With .Cells(nextRow, "3,2")
'was b3
End With
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(xlCellTypeConstants)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub
Bookmarks