aheverett1
New Member
- Joined
- May 23, 2017
- Messages
- 16
I cannot figure out where i am going wrong with my code here, any help would be appreciated. I originally wrote this code to put the info into 1 of 3 ranges depending on which option button is checked. Now i need to also have it put the data into a separate worksheet in the first blank row. This entire separate worksheet is blank as well by the way.
So here is my code. Everything works great and has no problems with the exception of the red text below. I'm at a loss of why this doesn't work, it's the same code as above, i'm just specifying a different worksheet and range i thought?
Private Sub CmdInsert_Click()
Dim FirstBlankCell As Range
If OptionButton1.Value = False And OptionButton2 = False And OptionButton3 = False Then
MsgBox "Must select fixture type"
Exit Sub
End If
If IsBlankTextBox = True Then
MsgBox "Must Enter Location"
Exit Sub
End If
If ComboBox1 = "" Then
MsgBox "Must select Fixture"
Exit Sub
End If
If Fixt_Quantity = "" Then
MsgBox "Must Enter Quantity"
Exit Sub
End If
If OptionButton1.Value = True Then
Range("A10:A50").SpecialCells(xlBlanks)(1).Select
ElseIf OptionButton2.Value = True Then
Range("A52:A64").SpecialCells(xlBlanks)(1).Select
ElseIf OptionButton3.Value = True Then
Range("A66:A105").SpecialCells(xlBlanks)(1).Select
End If
ActiveCell.Value = Location.Text
ActiveCell.Offset(, 1) = Fixt_Quantity.Text
ActiveCell.Offset(, 3) = ComboBox1.Text
ActiveCell.Offset(, 7) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:B444"), 2, False)
ActiveCell.Offset(, 6) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:C444"), 3, False)
If OptionButton2.Value = True Then
Sheets("OptionHelper").Range("A1:A25").SpecialCells(xlBlanks)(1).Select
End If
ActiveCell.Value = Location.Text
ActiveCell.Offset(, 1) = Fixt_Quantity.Text
ActiveCell.Offset(, 3) = ComboBox1.Text
ActiveCell.Offset(, 7) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:B444"), 2, False)
ActiveCell.Offset(, 6) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:C444"), 3, False)
Location.Value = ""
Fixt_Quantity.Value = ""
ComboBox1.Value = ""
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
End Sub
So here is my code. Everything works great and has no problems with the exception of the red text below. I'm at a loss of why this doesn't work, it's the same code as above, i'm just specifying a different worksheet and range i thought?
Private Sub CmdInsert_Click()
Dim FirstBlankCell As Range
If OptionButton1.Value = False And OptionButton2 = False And OptionButton3 = False Then
MsgBox "Must select fixture type"
Exit Sub
End If
If IsBlankTextBox = True Then
MsgBox "Must Enter Location"
Exit Sub
End If
If ComboBox1 = "" Then
MsgBox "Must select Fixture"
Exit Sub
End If
If Fixt_Quantity = "" Then
MsgBox "Must Enter Quantity"
Exit Sub
End If
If OptionButton1.Value = True Then
Range("A10:A50").SpecialCells(xlBlanks)(1).Select
ElseIf OptionButton2.Value = True Then
Range("A52:A64").SpecialCells(xlBlanks)(1).Select
ElseIf OptionButton3.Value = True Then
Range("A66:A105").SpecialCells(xlBlanks)(1).Select
End If
ActiveCell.Value = Location.Text
ActiveCell.Offset(, 1) = Fixt_Quantity.Text
ActiveCell.Offset(, 3) = ComboBox1.Text
ActiveCell.Offset(, 7) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:B444"), 2, False)
ActiveCell.Offset(, 6) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:C444"), 3, False)
If OptionButton2.Value = True Then
Sheets("OptionHelper").Range("A1:A25").SpecialCells(xlBlanks)(1).Select
End If
ActiveCell.Value = Location.Text
ActiveCell.Offset(, 1) = Fixt_Quantity.Text
ActiveCell.Offset(, 3) = ComboBox1.Text
ActiveCell.Offset(, 7) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:B444"), 2, False)
ActiveCell.Offset(, 6) = Application.WorksheetFunction.VLookup(ActiveCell.Offset(, 3), Sheets("DataSheet").Range("A70:C444"), 3, False)
Location.Value = ""
Fixt_Quantity.Value = ""
ComboBox1.Value = ""
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
End Sub