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 Souzaj
Posts
#14519
Bom dia,

Não tenho conhecimento quase nenhum no excel por isso estou com uma duvida que acredito ser simples porém não estou conseguindo fazer.

estou criando uma planilha que em todas as linha da coluna A vão ter um checkbox e vinculei o resultado para a célula da B porém quando meu arrasto para criar varios checkbox todos eles fica vinculado a primeira célula, por exemplo: A1 vinculado a B1 ai eu crio varias copias do checkbox e todos eles fica vinculado a B1

E eu preciso que A1 fique vinculado a B1, A2 vinculado a B2 e assim por diante. Fazendo manual eu consigo porém essa minha planilha vão ter 30000 checkbox na coluna A, então fazendo manualmente iria dar um trabalhozinho até bom.
Avatar do usuário
Por alexandrevba
Avatar
#14520
Bom dia!!

O primeiro código cria as checkbox, o segundo código linca com as células.
Código: Selecionar todos
Sub ActX_Add_Multiple_CheckBox_Ex1()
'Fonte:http://analysistabs.com/vba/add-checkbox-on-worksheet-or-userform-using-vba/
'Disable Screen Update
Application.ScreenUpdating = False
'Variable Declaration
Dim Rng As Range
Dim ShtRng As Range
Dim WrkSht As Worksheet
Dim i As Integer
'Variable Initialization
i = 1
Set ShtRng = Application.Selection
Set ShtRng = Application.InputBox("Range", "Selecione o Intervalo", ShtRng.Address, Type:=8)
Set WrkSht = Sheets("Plan1")
    For Each Rng In ShtRng
        With WrkSht.CheckBoxes.Add(Left:=Rng.Left, Top:=Rng.Top, Width:=Rng.Width, Height:=Rng.Height).Select
            With Selection
                .Characters.Text = Rng.Value
                .Caption = ""
                .Caption = "Check Box " & i
                i = i + 1
            End With
        End With
    Next
ShtRng.ClearContents
ShtRng.Select
'Enable Screen Update
Application.ScreenUpdating = True
End Sub
Código: Selecionar todos
Sub LinkCheckBoxes()
'Fonte:http://blog.contextures.com/archives/2014/01/14/click-a-cell-to-check-yes-or-no/
Dim chk As CheckBox
Dim lCol As Long
lCol = 1 'number of columns to the right for link

For Each chk In ActiveSheet.CheckBoxes
   With chk
      .LinkedCell = _
         .TopLeftCell.Offset(0, lCol).Address
   End With
Next chk

End Sub
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