PDA

View Full Version : Auto fill Cells Down if other cells have information



LearningEXL
04-15-2015, 10:16 AM
i have a userform that puts information into cells and works great however the dont run in order which again is ok. (when i say order i mean col 1 2 3 4 5 6 7 17 18)

in cols 8 through 16 have formulas in and work based on the information that is entered - again works great

however my issue is this.

when i add this information via the userform and add new information which is sorted by date it does not add the cells that have the formulas in or should i say that dont auto fill the cells with the formulas in down.

this is my add button code if that helps


Private Sub cmdAdd_Click()On Error GoTo cmdAdd_Click_Error
'make sure that there is data to add
If Me.DT_Date.Value = "" _
Or Me.Cbo_Agency.Value = "" _
Or Me.Cbo_ACon.Value = "" _
Or Me.Cbo_DayType.Value = "" _
Or Me.Cbo_NightOut.Value = "" _
Or Me.Txt_ST.Value = "" _
Or Me.Txt_ET.Value = "" _
Or Me.Cbo_Break.Value = "" _
Or Me.Cbo_DTime.Value = "" Then
Call MsgBox("The fields are not complete", vbInformation, "Agency Timesheet")
Exit Sub
End If
If Sheet7.Range("B9").Value = "" Then
Sheet7.Range("B9:T9").FormulaArray = "1"
End If
'set the destination range
Set Drng = Sheet7.Range("b8")
'move the values without selecting
Drng.End(xlDown).Offset(1, 0).Value = Me.DT_Date.Value '*****this is your first col
Drng.End(xlDown).Offset(0, 1).Value = Me.Cbo_Agency.Value
Drng.End(xlDown).Offset(0, 2).Value = Me.Cbo_ACon.Value
Drng.End(xlDown).Offset(0, 3).Value = Me.Cbo_DayType.Value
Drng.End(xlDown).Offset(0, 4).Value = Me.Cbo_NightOut.Value
Drng.End(xlDown).Offset(0, 5).Value = Me.Txt_ST.Value
Drng.End(xlDown).Offset(0, 6).Value = Me.Txt_ET.Value
Drng.End(xlDown).Offset(0, 12).Value = Me.Cbo_Break.Value
Drng.End(xlDown).Offset(0, 16).Value = Me.Cbo_DTime.Value
Drng.End(xlDown).Offset(0, 18).Value = Drng.End(xlDown).Offset(-1, 17).Value + 1
'give the "all OK signal"
Call MsgBox("A new Shift has been added", vbInformation, "Add Shift")
'sort the data
ClearList_ATS
Sortit_ADI
On Error GoTo 0
Exit Sub
'if error occurs then show me exactly where the error occurs
cmdAdd_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAdd_Click of Form Agency Daily Input"
End Sub

mancubus
04-15-2015, 10:34 PM
can you post your workbook with sample data?