Página 1 de 1

Botão voltar flutuante

Enviado: 07 Out 2021 às 10:11
por Angrass
Bom dia

Option Explicit
Private Sub CommandButton1_Click()
Range("a1").Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Targed As Excel.Range)
Dim effectiveBottomRow As long
Dim my Commandbutton1 As Object
Set myCommandButton1 = ActiveSheet.commandButton1:
With ActiveWindow.VisibleRange
Commandbutton1.Top = .Top + 0
Commandbutton1.Left = .Left + .Width - CommandButton1.Width - 7
End With
End Sub

Rodava normal, agora dá erro de compilação
:roll: :roll:

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 10:58
por babdallas
Anexa a planilha por favor para que possamos depurar.

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 11:54
por Angrass
Ok

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 12:57
por babdallas
Aqui não deu erro algum. Em qual linha deu erro para você?

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 13:43
por Angrass
Perdi diversas macros de diversas planilhas depois de fazer atualização do office 2010 para o 2013 e algumas macros como essa apresentam erros. Desinstalei o 2013 e voltei com o 2010 e sumiu quase tudo

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 13:48
por babdallas
Eu rodei no Office 365 e funcionou normalmente, Qual linha deu erro no Excel 2013?

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 13:58
por Angrass
Imagem
Imagem

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 14:13
por babdallas
Tente colocar ActiveSheet.CommandButton1 onde estiver apenas CommandButton1.

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 15:08
por Angrass
Erro em tempo de execução '438':
O objeto não aceita esta propriedade ou método


Set myCommand Button1 =ActiveSheet.CommandButton1:

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 15:17
por babdallas
Tente isso
Código: Selecionar todos
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    Dim myCommandButton1 As Object
    
    Set myCommandButton1 = ActiveSheet.CommandButton1
    
    With ActiveWindow.VisibleRange
        myCommandButton1.Top = .Top + 20
        myCommandButton1.Left = .Left + .Width - myCommandButton1.Width - 52
    End With
End Sub

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 15:25
por Angrass
Set myCommandButton1 = ActiveSheet.CommandButton1

Erro em tempo de execução 438
Objeto não aceita esta propriedade ou método


Vou desinstalar e instalar o office outra vez.

Re: Botão voltar flutuante

Enviado: 07 Out 2021 às 15:36
por Angrass
Testei em outro office 365 e a macro rodou normal. Meu Office tá bichado.
Grato pela ajuda :D :D