I get an error on the line: "Columns("4:4").insert Shift
ltoright, copy origin:=xlformatfromleftorabove
The error is "Application defined or object defined error"
The variables are defined in a separate module as public variables, and I do not have any variable called "Columns"
The error is "Application defined or object defined error"
The variables are defined in a separate module as public variables, and I do not have any variable called "Columns"
Code:
Option ExplicitSub Offset_Time()
File.Activate
Sheets(1).Select
'Set the value of the Time_Offset variable
If ThisWorkbook.Sheets(1).OLEObjects("optionbutton1").Object.Value = True Then Time_Offset = Cells(26, "E")
If ThisWorkbook.Sheets(1).OLEObjects("optionbutton2").Object.Value = True Then Time_Offset = Cells(27, "E")
If ThisWorkbook.Sheets(1).OLEObjects("optionbutton3").Object.Value = True Then Time_Offset = Cells(28, "E")
If ThisWorkbook.Sheets(1).OLEObjects("optionbutton4").Object.Value = True Then Time_Offset = Cells(29, "E")
If ThisWorkbook.Sheets(1).OLEObjects("optionbutton5").Object.Value = True Then Time_Offset = Cells(30, "E")
'Insert a row and give it a header
Columns("4:4").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(1, 4) = "Time_sec"
'Figure out when the vehicle starts moving, set it equal to a variable
Vehicle_Speed_Col = Application.Match("Vehicle_Speed_Avg_Front_Wheels", Rows("1:1"), 0)
For i = 1 To Quan_Rows_File
If Cells(i, Vehicle_Speed_Col) > 0 Then
First_Movement_Line = i
Exit For
End If
Next i
'Start populating the new channel
For i = 2 To Quan_Rows_File
Cells(i, "D") = Time_Offset + (0.1 * (i - First_Movement_Line))
Next i
End Sub