Jump to content
Fórum Script Brasil
  • 0

Erro 1004



Boa noite Galera!

O código abaixo apresenta o erro 1004 quanto chega na linha : Set B = Range(Worksheets("Cotas").Cells(Linha_q, mypIBOV), Worksheets("Cotas").Cells(ultima_linha, mypFundo))

Não manjo muito de VBA :( 

Algém pode ajudar?

Private Sub CommandButton1_Click5()
Dim snome As String
Dim mypFundo As Integer
Dim mypSMLL As Integer
Dim Data As Date
Dim mypIBOV As Integer
Dim data_init As Date
Dim Data_InitVer As Date
Dim Linha_q As Integer
Dim irow As Integer
Dim Correlation As Double
Dim Res As Variant
Dim A As Range
Dim B As Range
Dim ultima_linha As Integer

    mypFundo = Worksheets("Cotas").Cells.Find("11.392.165/0001-72").Column
    mypSMLL = Worksheets("Cotas").Cells.Find("SMLL").Column
    mypIBOV = Worksheets("Cotas").Cells.Find("Ibovespa").Column

    ultima_linha = Worksheets("Cotas").Cells(Rows.Count, mypFundo).End(xlUp).Row
    Data = Worksheets("Cotas").Cells(ultima_linha, 1)
    'meio que tu tem usando o irow já calculado
    ano = Year(Data)
    data_init = DateSerial(ano, 1, 1)
    'é o primeiro dia útil?

    Data_InitVer = Application.WorksheetFunction.WorkDay(data_init, 1, Worksheets("Feriados").Range("A1:A1000"))

    snome = ActiveWorkbook.Name
    Res = Application.Match(CDbl(Data_InitVer), Workbooks(snome).Worksheets("Cotas").Columns(1), 0)
    If Not IsError(Res) Then
        Linha_q = Res
    End If


   Set A = Range(Cells(Linha_q, mypFundo), Cells(ultima_linha, mypFundo))
    irow = Worksheets("Cotas").Cells(Rows.Count, mypFundo).End(xlUp).Row

'Set A = Range(Worksheets("Cotas").Cells(Linha_q, mypFundo), Worksheets("Cotas").Cells(ultima_linha, mypFundo))
Set B = Range(Worksheets("Cotas").Cells(Linha_q, mypIBOV), Worksheets("Cotas").Cells(ultima_linha, mypFundo))

    Correlation = Application.WorksheetFunction.Correl(A, B)
End Sub

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...