The value of a cell in a VBA variable

Solved
Hello everyone. Well, I have a big problem in Excel and I think it's a bit complicated to explain.
So I would like to go step by step.

First of all, how can I place the value of a cell in a VBA variable?

It may seem like a silly problem, but I'm a bit stuck on this silliness.

Best regards

Grobibi34
Configuration: Windows XP Internet Explorer 6.0

3 answers

  1. Hi Grobibi,
    1°) declare your variable:
    Dim NomVariable

    2°) assign it the value of a cell:
    NomVariable = range("A1").Value

    If necessary, refer to the workbook and the sheet:
    NomVariable = Workbooks("NomClasseur").Sheets("NomFeuille").Range("A1").Value


    Keep up the good work!
    124
    1. Suuuuuper, it works perfectly, thank you very much Ivan-hoe ;-)
      26
    2. Hello,

      I'm looking for a way to do the opposite, that is to say, to copy the value of a variable into a cell of a workbook.

      Actually, I created a form template to generate invoices. I need the invoice number to increment by 1 for each new invoice.

      I'm struggling to do this. I managed to make it work when opening the template by creating an Auto_Open procedure, but it doesn't work when creating a new document from this template.

      I'm sure it's possible to do it using a variable that keeps the values and which would be written each time an invoice is created, but I haven't found it.

      Could you help me?
      0
    3. Thank you for your perfect solution =)
      0
    4. Thank you, it was very helpful to me (plus, I gave you +1).
      0
    5. The return of the ghost post!

      I just have a question regarding the usage.

      I defined the variable "nbrjan" as the row name of the January sheet.
      How do I use this variable to define a cell?

      Example that doesn't work:

      Sheet(january).Range("A1", "R" & nbrjan).Select
      0