Apologies for the lengthy title. I have never done anything using a check box. What needs to be accomplished is when the check box is selected all the data that is in the userform will be copied and redirected to a worksheet. Currently when the command button is selected it copies all the data and pastes into two different worksheets, but I'm trying to make it where if the box is checked it copies only to a completely different tab. Current userform code is below:
Code:
Private Sub CommandButton1_Click()
Dim lg As Worksheet
Set lg = Sheets("Log")
Set bol = Sheets("BOL")
Set Slog = Sheets("Seal Log_Make Changes Here")
bol.Cells(4, 14) = Me.DoorCB
bol.Cells(5, 2) = CDate(Me.DateTB)
bol.Cells(11, 10) = Me.SortTB
bol.Cells(12, 10) = Me.TrailerCB
bol.Cells(13, 3) = Me.AddressTB
bol.Cells(14, 10) = Me.SealTB
bol.Cells(15, 10) = Me.CarrierCB
bol.Cells(13, 10) = Me.VRIDTB
bol.Cells(36, 1) = Me.QtyTB
bol.Cells(36, 5) = Me.WeightTB
bol.Cells(50, 7) = Me.CPTTB
bol.Cells(50, 2) = Me.ArrivalTB
bol.Cells(51, 2) = Me.DepartTB
lg.Select
lg.Range("A2:J2").Select
Selection.ListObject.ListRows.Add (1)
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
lg.Cells(2, 1) = CDate(Me.DateTB)
lg.Cells(2, 2) = Me.SortTB
lg.Cells(2, 3) = Me.CarrierCB
lg.Cells(2, 4) = Me.TrailerCB
lg.Cells(2, 5) = Me.VRIDTB
lg.Cells(2, 6) = Me.SealTB
lg.Cells(2, 7) = Me.QtyTB
lg.Cells(2, 8) = Me.WeightTB
lg.Cells(2, 9) = Me.DoorCB
lg.Cells(2, 10) = Me.CaseTB
lg.Cells(2, 12) = Me.ArrivalTB
lg.Cells(2, 13) = Me.DepartTB
lg.Cells(2, 15) = UCase(Me.InitalsTB)
Slog.Select
Slog.Range("G1:M1").Select
Selection.Insert Shift:=xlDown
Slog.Cells(7, 7) = Me.SealTB
Slog.Cells(7, 8) = "KN"
Slog.Cells(7, 9) = CDate(Me.DateTB)
Slog.Cells(7, 10) = Me.VRIDTB
Slog.Cells(7, 11) = Me.SortTB & " " & Me.TrailerCB
Slog.Cells(7, 12) = UCase(Me.InitalsTB)
Slog.Cells(7, 13) = Me.UsernameTB
Range("G7:L197").Select
Selection.Copy
Range("A7").Select
ActiveSheet.Paste
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5").Sort. _
SortFields.Add(Range("Table5[SEAL NUMBER]"), xlSortOnFontColor, xlAscending, , _
xlSortNormal).SortOnValue.Color = RGB(0, 0, 255)
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5").Sort. _
SortFields.Add Key:=Range("Table5[SEAL NUMBER]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table57").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table57").Sort. _
SortFields.Add(Range("Table57[SEAL NUMBER]"), xlSortOnFontColor, xlAscending, , _
xlSortNormal).SortOnValue.Color = RGB(0, 0, 255)
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table57").Sort. _
SortFields.Add Key:=Range("Table57[SEAL NUMBER]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table57").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table578").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table578").Sort. _
SortFields.Add(Range("Table578[SEAL NUMBER]"), xlSortOnFontColor, xlAscending, , _
xlSortNormal).SortOnValue.Color = RGB(0, 0, 255)
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table578").Sort. _
SortFields.Add Key:=Range("Table578[SEAL NUMBER]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table578").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5789").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5789").Sort. _
SortFields.Add(Range("Table5789[SEAL NUMBER]"), xlSortOnFontColor, xlAscending, , _
xlSortNormal).SortOnValue.Color = RGB(0, 0, 255)
ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5789").Sort. _
SortFields.Add Key:=Range("Table5789[SEAL NUMBER]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Seal Control Log").ListObjects("Table5789").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Unload Me
bol.Select
End Sub
Last edited by a moderator: