1

I´m trying to store range using variables, but I get "Method Range global failed" or they keeps empty. Can anyone help me? The two variables are UltimaAmostra e CabecarioIsotopos.

Sub MediaBCOGJbrutos()

    Dim Amostra As String 'Variável com o endereço da amostra
    Dim n As Long 'Variável que controlará a linha onde se encontra o endereço da amostra a ser aberta


    Dim EnderecoAmostras As Range 'Intervalo da planilha com o endereço dos arquivos de cada amostra
    Dim UltimaAmostra As Range 'Célula correspondente à ultima amostra
    Dim CabecarioIsotopos As Range 'Intervalo dentro de cada planilha .dynamic.exp onde se encontram os cabeçários da colunas

    Workbooks("Recuperar (simplificada)").Sheets("DadosProcessados").Activate

            n = 2

           Set EnderecoAmostras = Range("B2", "B" & Range("B2").End(xlDown).Row)


1    With EnderecoAmostras 'O número 1 à esquerda é uma referência para a macro seja executada a partir daqui sob certas condições
        For n = 2 To .Rows.Count
            Amostra = Cells(n, 2)
            Workbooks.Open Filename:=Amostra
        n = n + 1

        Set CabecarioIsotopos = Range("A15:U15")
Community
  • 1
  • 1
Felipe
  • 163
  • 3
  • 7
  • 21
  • On which row do you get the error? – Joe Nov 06 '13 at 18:47
  • 3
    [INTERESTING READ](http://stackoverflow.com/questions/10714251/excel-macro-avoiding-using-select) And to find the last row, see [THIS](http://stackoverflow.com/questions/11169445/error-finding-last-used-cell-in-vba) If you follow these two links then your problems will be solved. – Siddharth Rout Nov 06 '13 at 18:48
  • Set EnderecoAmostras = Range("B2", "B" & Range("B2").End(xlDown).Row) – Felipe Nov 06 '13 at 18:48
  • Thank you Siddharth Rout, I´m reading right now. – Felipe Nov 06 '13 at 18:51

0 Answers0