Tengo problemas con una macros no suma ni resta la cantidad que se introduce y me aparece error 91

básicamente la macros debe descontar o sumar la cantidad que se introduce según el tipo de movimiento suma si es "entrada" y resta si es "salida" la demás parte de la macros me anda bien pero en esta parte no se que pasa ya que me marca error 91 pero ya revise todo y según yo esta todo declarado me pueden ayudar, me esta volviendo loco.

$$\begin{align}&Dim strcod$, strrango$\\ &Dim ingvalorstock&, ingcant&\\ &\\ &Sub Botón20_Haga_clic_en()\\ &\\ &Dim strmed$\\ &Dim ingvalorcant&, ingnuevovalor&, ingvalorstock&\\ &Dim articulo As String\\ &Dim stremp$, strnom$, strcat$, strfing$, strcod$, strtipo$, strarea$, strevent$\\ &Dim dathoy As Date\\ &\\ &Application.ScreenUpdating = False\\ &' si falta no. De empleado\\ &If [E9] = "" Then\\ &MsgBox "Ingrese No. De Empleado", vbExclamation + vbOKOnly, "Falta numero de Empleado"\\ &Application.ScreenUpdating = True\\ &Exit Sub\\ &\end If\\ &'si falta codigo de articulo\\ &If [E14] = "" Then\\ &MsgBox "Ingrese codigo de Articulo", vbExclamation + vbOKOnly, "Falta codigo de Articulo"\\ &Application.ScreenUpdating = True\\ &Exit Sub\\ &\end If\\ &'si falta cantidad a despachar\\ &If [E16] = "" Then\\ &MsgBox "Ingrese cantidad a despachar", vbExclamation + vbOKOnly, "Falta cantidad"\\ &Application.ScreenUpdating = True\\ &Exit Sub\\ &\end If\\ &'si falta el tipo de movimento a registrar\\ &If [E17] = "" Then\\ &MsgBox "Ingrese Tipo de Movimiento Entrada/Salida", vbExclamation + vbOKOnly, "Falta Movimiento"\\ &Application.ScreenUpdating = True\\ &Exit Sub\\ &\end If\\ &\\ &' ingcant& = cantidad de producto entregado\\ &' ingevent& = numero de Evento registrado\\ &' stremp$ = numero de Empleado\\ &' strnom$ = Nombre de Empleado\\ &' strcat$ = categoria de emplado\\ &' strarea$ = area de empleado\\ &' strfing$ = fecha de ingreso de empleado\\ &' strcod$ = codigo de producto entregado\\ &' strart$ = nombre de Articulo entregado\\ &' strtipo$ = tipo de movimiento entra/salida\\ &' dathoy = Fecha Actual\\ &\\ &ingcant& = [E16]: stremp$ = [E9]: strnom$ = [E10]: strfing$ = [E13]: strcat$ = [E11]: strarea$ = [E12]\\ &strcod$ = [E14]: articulo = [E15]: strtipo$ = [E17]: strevent$ = [C8]\\ &dathoy = Date\\ &\\ &'cadena original\\ &\\ &Sheets("STOCK").Select\\ &[B1].Select\\ &\\ &ingvalorstock& = [B:B].Find(What:=strcod$, After:=ActiveCell, LookIn:=xlFormulas, LookAt _\\ &         :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _\\ &         False, SearchFormat:=False).Offset(0, 4).Value\\ &\\ &strrango$ = [B:B].Find(What:=strcod$, After:=ActiveCell, LookIn:=xlFormulas, LookAt _\\ &        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _\\ &        False, SearchFormat:=False).Offset(0, 4).Address\\ &\\ &If strtipo$ = "Salida" Then\\ &\\ &If lngvalorstock& < lngcant& Then\\ &MsgBox "El stock de " & strdescrip$ & " es menor (" _\\ && lngvalorstock& & ") al de su parte (" & lngcant& & ")", vbExclamation + vbOKOnly, "STOCK MENOR"\\ &Sheets("Entradas-Salidas").Select\\ &Application.ScreenUpdating = True\\ &Exit Sub\\ &\end If\\ &\\ &Range(strrango$) = valorstock& - lngcant&\\ &lngnuevovalor& = Range(strrango$)\\ &\end If\\ &\\ &If strtipo$ = "Entrada" Then\\ &Range(strrango$) = lngcant& + valorstock&\\ &lngnuevovalor& = Range(strrango$)\\ &\end If\\ &\\ &Sheets("RECIBO").Select\\ &\\ &[B65536].\end(xlUp).Offset(1, 0) = lngnumero&\\ &[B65536].\end(xlUp).Offset(0, 0) = strcod$ 'CODIGO'\\ &[B65536].\end(xlUp).Offset(0, 1) = articulo 'Descripcion'\\ &[B65536].\end(xlUp).Offset(0, 2) = lngcant&  'Cantidad'\\ &\\ &'cadena original\\ &\\ &Sheets("Registro").Select\\ &\\ &[B65536].\end(xlUp).Offset(1, 0) = strevent$ 'numero de evento'\\ &[B65536].\end(xlUp).Offset(0, 1) = stremp$ 'Numero de empleado'\\ &[B65536].\end(xlUp).Offset(0, 2) = strnom$ 'Nombre de empleado'\\ &[B65536].\end(xlUp).Offset(0, 3) = strcat$ 'Categorida de empleado'\\ &[B65536].\end(xlUp).Offset(0, 4) = strarea$ 'Area de Empleado'\\ &[B65536].\end(xlUp).Offset(0, 5) = strfing$ 'Fecha de ingreso de empleado'\\ &[B65536].\end(xlUp).Offset(0, 6) = strcod$ 'Codigo de Producto'\\ &[B65536].\end(xlUp).Offset(0, 7) = articulo 'Nombre de Articulo'\\ &[B65536].\end(xlUp).Offset(0, 8) = ingcant& 'cantidad a despachar'\\ &[B65536].\end(xlUp).Offset(0, 9) = strtipo$ ' Movimiento realizado'\\ &[B65536].\end(xlUp).Offset(0, 10) = dathoy 'fecha de movimiento'\\ &\\ &MsgBox "Su stock de " & articulo & " fue actualizado de " _\\ && lngvalorstock& & " a " & lngnuevovalor&, vbExclamation + vbOKOnly, "STOCK ACTUALIZADO"\\ &\\ &Sheets("Panel").Select\\ &[E9,E14,E16,E17].ClearContents\\ &Sheets("Panel").Select\\ &[E9].Select\\ &\\ &\end Sub\\ &\\ &\end{align}$$

en esta parte debería buscar según el código en este caso strcod$ y sumar o restar con le valor de ingcant& pero me dice que de 0 cambio a 0 y al depurar me marca 91 justo desde aquí

$$\begin{align}&\\ &ingvalorstock& = [B:B].Find(What:=strcod$, After:=ActiveCell, LookIn:=xlFormulas, LookAt _\\ &         :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _\\ &         False, SearchFormat:=False).Offset(0, 4).Value\\ &\\ &strrango$ = [B:B].Find(What:=strcod$, After:=ActiveCell, LookIn:=xlFormulas, LookAt _\\ &        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _\\ &        False, SearchFormat:=False).Offset(0, 4).Address\\ &\\ &If strtipo$ = "Salida" Then\\ &\\ &If lngvalorstock& < lngcant& Then\\ &MsgBox "El stock de " & strdescrip$ & " es menor (" _\\ && lngvalorstock& & ") al de su parte (" & lngcant& & ")", vbExclamation + vbOKOnly, "STOCK MENOR"\\ &Sheets("Entradas-Salidas").Select\\ &Application.ScreenUpdating = True\\ &Exit Sub\\ &\end If\\ &\\ &Range(strrango$) = valorstock& - lngcant&\\ &lngnuevovalor& = Range(strrango$)\\ &\end If\\ &\\ &If strtipo$ = "Entrada" Then\\ &Range(strrango$) = lngcant& + valorstock&\\ &lngnuevovalor& = Range(strrango$)\\ &\end If\\ &\\ &\end{align}$$

saludos

Añade tu respuesta

Haz clic para o