Página 1 de 1

LOOP CONDICIONAL

Enviado: 06 Fev 2020 às 17:58
por LuisAlvarenga
Mais uma vez peço ajuda.

Estou com uma rotina While, e dentro dela quero colocar uma ou mais condições com if e desviar (loop) naquele ponto.

With Plan1
Do While .Cells(Linha, 1).Value <> ""

Data = .Cells(Linha, 1).Value
DataPag = .Cells(Linha, 6).Value

If ckPagos.Value = True And DataPag = "" Then
' minha dúvida aqui
' quero dar um loop aqui
End If
If CkPend.Value = True And DataPag <> "" Then
' minha dúvida aqui
' quero dar um loop aqui
End If

If Data >= DataIni And Data <= DataFim Then

With ListBox1
.AddItem
.List(LinhaListBox, 0) = Plan1.Cells(Linha, 1)
.List(LinhaListBox, 1) = Plan1.Cells(Linha, 2)
.List(LinhaListBox, 2) = Plan1.Cells(Linha, 3)
.List(LinhaListBox, 3) = Plan1.Cells(Linha, 4)
cValor = CStr(Format(Plan1.Cells(Linha, 5), "###,##0.00"))
.List(LinhaListBox, 4) = Space(10 - Len(cValor)) & cValor
.List(LinhaListBox, 5) = Plan1.Cells(Linha, 6)

If DataPag = "" Then
nTotPend = nTotPend + Plan1.Cells(Linha, 5)
Else
nTotPago = nTotPago + Plan1.Cells(Linha, 5)
End If


End With
LinhaListBox = LinhaListBox + 1

End If

Linha = Linha + 1

Wend

End With

Minha origem é CLIPPER e estou sofrendo com as mudanças.


Agradeço ..

Re: LOOP CONDICIONAL

Enviado: 07 Fev 2020 às 07:41
por babdallas
Tente explicar que tipo de loop você deseja fazer depois do if. Qual o comportamento que você deseja que seu código execute? Se responder a isso ficará mais fácil de ajudar.

LOOP CONDICIONAL

Enviado: 07 Fev 2020 às 11:10
por lucasExcel
Experimenta implementar o IF com o Select Case

LOOP CONDICIONAL

Enviado: 07 Fev 2020 às 12:45
por LuisAlvarenga
Obrigado