Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Por fjjohann
Posts
#8383
Olá,, a macro a seguir é utilizada para ocultar as linhas 10 até 13 caso o valor da coluna c9 seja 1.
Como faço pra em vez de colocar "10:13", vincular o valor de uma celula.
por exemplo, na célula g211 consta o valor 10 e na j211 consta o valor 11.
como devo escrever: "10:13" -> "g211:j211" ??


Sub Ocultainicial()
If Range("c9").Value = "1" Then
Rows("10:13").Hidden = True


Else
Rows("10:13").Hidden = False

End If

End Sub
#8388
Bom dia!!

Eu não sei se entendi...
Código: Selecionar todos
Sub Ocultainicial()
Dim interestingRows As Range
startRow = Range("G211").Value 'Dessa linha
endRow = Range("J211").Value   'Até essa linha
Set interestingRows = Plan1.Range(startRow & ":" & endRow)

    If Range("c9").Value = "1" Then
        interestingRows.EntireRow.Hidden = True
    Else
        Rows("10:13").Hidden = False
    End If
End Sub
Att
Por fjjohann
Posts
#8389
Oi Alexandre, acho que é isso, mas tenho que referenciar onde está em vermelho tbm, como faço?


Sub Ocultainicial()
Dim interestingRows As Range
startRow = Range("G211").Value 'Dessa linha
endRow = Range("J211").Value 'Até essa linha
Set interestingRows = Plan1.Range(startRow & ":" & endRow)

If Range("c9").Value = "1" Then
interestingRows.EntireRow.Hidden = True
Else
Rows("10:13").Hidden = False
End If
End Sub
#8391
Boa tarde!!

Tente assim...
Código: Selecionar todos
Sub Ocultainicial()
Dim interestingRows As Range
Dim interestingRowsB As Range

startRow = Range("G211").Value 'Dessa linha
endRow = Range("J211").Value 'Até essa linha

startRowB = Range("SuaCélula").Value 'Dessa linha
endRowB = Range("SuaCélula").Value 'Até essa linha

Set interestingRows = Plan1.Range(startRow & ":" & endRow)
Set interestingRowsB = Plan1.Range(startRowB & ":" & endRowB)


    If Range("c9").Value = "1" Then
        interestingRows.EntireRow.Hidden = True
    Else
        interestingRowsB.EntireRow.Hidden = True
    End If

End Sub
Obs: Não testado!!

Att
Por fjjohann
Posts
#8393
Alexandre,

infelizmente não funcionou, quando executo a macro, tanto faz o valor da célula "c9", seja 0 ou seja 1, não oculta as linhas nem expande.
#8399
Boa tarde!!

Vamos considerar que eu entendi sua dúvida...

O código faz o seguinte, em G211 tem o valo 7 e em J211 o valor 10, o código vai considerar que vc pretende ocultar as linhas 7 até 10 caso c9 tenh o valor 1.

para tal o código funciona, se não for isso, por gentileza faça me entender. :?

Att
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord