rodolfon
06-12-2016, 11:56 AM
Hi, People
If anyone can give me a help I would greatly appreciate it!
I am developing a simple macro that will filter the content of some columns, you will get the address of the desired cell, select those cells, and then it will plot on a graph!
In fact, the macro will end a little more complex, but I'm developing this initially and then refine the process as well:
Initially I have some data ranging from B4 to something, I have to check which cells in this range have a value (in the example I'm using 0.5) when I find that value, I store the ordered pairs (Xi, Yi), where "i" is the line number where I am! Everything works beauty in getting the address, the problem is to select the Range!
I will post some of the code here to stay understanding easier:
Sub Teste()
'Declaração de variáveis
Dim celula As Range
Dim minvalue As Double
Dim enderecos As String
Dim enderecosunion As String
'Determinação do valor das variáveis
minvalue = 0.5
'Verificacao dos Filtros e obtenção dos endereços
For Each celula In Range("B4:" & ActiveSheet.Range("B65536").End(xlUp).Address).Cells
If celula.Value = minvalue Then
enderecos = enderecos & "," & celula.Offset(0,1).Address(False, False) & _
"," & celula.Offset(0, 4).Address(False, False)
End If
Next
enderecos = Right(enderecos, Len(enderecos) - 1)
Range(enderecos).Select
End Sub
Everything works fine, however, when selecting the cells obtained, I get the following error:
Run-time error '1004'
Method 'Range' of object '_Global' failed
I tried using the union function, however, the interval obtained does not work to plot the graph!
Does anyone know how to solve this?
thank you so much
If anyone can give me a help I would greatly appreciate it!
I am developing a simple macro that will filter the content of some columns, you will get the address of the desired cell, select those cells, and then it will plot on a graph!
In fact, the macro will end a little more complex, but I'm developing this initially and then refine the process as well:
Initially I have some data ranging from B4 to something, I have to check which cells in this range have a value (in the example I'm using 0.5) when I find that value, I store the ordered pairs (Xi, Yi), where "i" is the line number where I am! Everything works beauty in getting the address, the problem is to select the Range!
I will post some of the code here to stay understanding easier:
Sub Teste()
'Declaração de variáveis
Dim celula As Range
Dim minvalue As Double
Dim enderecos As String
Dim enderecosunion As String
'Determinação do valor das variáveis
minvalue = 0.5
'Verificacao dos Filtros e obtenção dos endereços
For Each celula In Range("B4:" & ActiveSheet.Range("B65536").End(xlUp).Address).Cells
If celula.Value = minvalue Then
enderecos = enderecos & "," & celula.Offset(0,1).Address(False, False) & _
"," & celula.Offset(0, 4).Address(False, False)
End If
Next
enderecos = Right(enderecos, Len(enderecos) - 1)
Range(enderecos).Select
End Sub
Everything works fine, however, when selecting the cells obtained, I get the following error:
Run-time error '1004'
Method 'Range' of object '_Global' failed
I tried using the union function, however, the interval obtained does not work to plot the graph!
Does anyone know how to solve this?
thank you so much