Consulting

Results 1 to 2 of 2

Thread: Bom dia! Estou com um problema em um progama de comparacao de valores.

  1. #1
    VBAX Newbie
    Joined
    Mar 2016
    Posts
    2
    Location

    Post Bom dia! Estou com um problema em um progama de comparacao de valores.

    Bom dia a todos, estou criando um progama que deve comparar um certo horário de 2 colunas em 2 planilhas diferentes, após comparar os valores o progama deve seguir a istrução no cógido, sem mais delongas, vamos direto ao problema: Minha variável B não está aumentando o valor (pulando para a proxima linha) pq ela só faz isso qnd o valor é MAIOR que o valor da Váriavel A. Eu não estou conseguindo compilar isso no progama. quando vou rodar o progama, apenas a variavel A retorna valor (por conta do FOR).

    
    
    Sub analisar()a = 6
    B = 7
    Menor = 0
    Maior = 0
    somaA = 6
    SomaB = 7
    ContA = Sheets("Boletim Produção").Cells(6, 42)
    ContB = Sheets("Boletim Parada").Cells(7, 4)
    
    
    For a = 6 To 5000
    
    
    
    
    If Sheets("Boletim Produção").Cells(a, 24) > Sheets("Boletim Parada").Cells(B, 3) Then
    
    
    Menor = ContA - 0.0007
    Maior = ContA + 0.0007
    
    
    If Menor < ContB And Maior > ContB Then
    
    
    
    
    ContA = ContA + Sheets("Boletim Produção").Cells(a + 1, 42)
    ContB = ContB + Sheets("Boletim Parada").Cells(B + 1, 4)
    Sheets("Boletim Produção").Cells(a, 42).Interior.Color = rgbGreen
    Sheets("Boletim Parada").Cells(B, 4).Interior.Color = rgbGreen
    Sheets("Boletim Produção").Cells(10, 47) = ContA
    a = a - 1
    B = B + 1
    
    
    Else
    If Sheets("Boletim Parada").Cells(B, 3) > Sheets("Boletim Produção").Cells(a, 24) And Sheets("Boletim Produção").Cells(a, 42) = 0 Then
    
    
    
    
    
    
    Sheets("Boletim Produção").Cells(a, 42).Interior.Color = rgbRed
    Sheets("Boletim Parada").Cells(B, 4).Interior.Color = rgbRed
    a = a - 1
    B = B + 1
    'ContA = Sheets("Boletim Produção").Cells(a, 42)
    'ContB = Sheets("Boletim Parada").Cells(B, 4)
    
    
    'Else
    'If Sheets("Boletim Produção").Cells(a, 42) = 0 Then
    'b = b + 1
    
    
    'ElseIf Sheets("Boletim Parada").Cells(b, 4) < Sheets("Boletim Produção").Cells(a, 24) Then
    'b = b + 1
    'a = a - 1
    
    
    
    
    
    
    'Else
    'Sheets("Boletim Produção").Cells(a, 42).Interior.Color = rgbRed
    'Sheets("Boletim Parada").Cells(b, 4).Interior.Color = rgbRed
    'End If
    
    
    Else
    Sheets("Boletim Produção").Cells(a, 42).Interior.Color = rgbGreen
    ContA = ContA + Sheets("Boletim Produção").Cells(a + 1, 42)
    
    
    
    
    End If
    End If
    End If
    
    
    Next
    End Sub


  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Duplicate thread, but I'm allowing it as it is in a second language.

    Also see thread:
    Help in VBA problems with Macro

    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •