Activecell.Formula compatibles types

Asked

Viewed 239 times

0

I am Using VBA and I came up with an impasse: I can use a variable I created as a parameter to fill a spreadsheet?

I created an interactive Button and I am developing an algorithm that fills the table, follows below the code:

Private Sub CommandButton1_Click()      'Adicionar gasto
    Dim data As String, nome As String, centro_custo As String, empresa As String, nf As String
    Dim dat_pgto As String, recebimento As String
    Dim iLinha As Integer, cont_contab As Integer, valor As Integer

    iLinha = 3
    data = InputBox("Digite a data de solicitação:")
    MsgBox ("Data: " & data)

    Do
        iLinha = iLinha + 1
    Loop Until Cells(iLinha, 1).Value = ""
    ActiveCell.Formula(iLinha, A) = data
End Sub
  • From what I’ve seen, you’re hoping that at the end of a value range, he’ll put the date you entered, right? I also see incorrect use of . formula property, penultimate line. I recommend you change to Range("A" & iLinha) = date

2 answers

1

The answer to your question "Can I use a variable I created as a parameter to fill in a spreadsheet?" is yes.

Just your code that’s a little weird, and I don’t quite understand what you want to do with it.

I’d do the ending this way:

     Do
            iLinha = iLinha + 1
     Loop Until Range(iLinha, 1).Value = ""
     Range(iLinha, A) = data
End Sub

If you specify better what you are trying to do, it becomes easier. Anything gives a touch :)

0

Activecell.Formula should only be used to place a formula in the cell, for example:

ActiveCell.Formula = "=IF(A1=B5;True;False)"

Remembering that the formula should always be written in English regardless of the language of your Office.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.