So i want a value from a text box, that is in a form, to be looked for, then i want the value's column and the columns from the left and the right to get deleted. But for some reason the Rango.Column is not getting the columns correctly. The code successfully finds the value.
Private Sub CommandButton1_Click()
Dim Rango As Range
Dim Prueba_N As String
Prueba_N = Partida.Txt.Value
If Prueba_N <> 0 Then
With Sheets("Prueba").Rows("6:6")
Set Rango = .Find(What:=Partida_N, After:=.Cells(.Cells.Count), LookIn:=xlValues, Lookat:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
End With
RangoC_1 = Rango.Column - 1
RangoC_2 = Rango.Column + 1
Sheets("Prueba").Range(Cells(1, RangoC_1), Cells(1, RangoC_2)).EntireColumn.Delete
Finalizar = MsgBox("Se ha eliminado la partida exitosamente")
Partida.Hide
Sheets("Materiales").Activate
Else
Partida_Err = MsgBox("Agregar Partida", vbCritical)
End If
End Sub
I also dont know why sometimes if i start the partida's form from the button it returns me the 1004 error on the Sheets("Prueba").Range...
line but if i start the form directly it doesnt give me the error.