VBA Course : Variables

Hi Guys

This is my first time on this forum. I like the course and am looking forward to learning and helping others in the process.

I started the VBA course the other day. In the VBA Variables none of the results are being returned on my trials even when I copy the solution directly to my VBA screen. Please if anyone has a moment I am pasting it here. I have commented the age row which shows the error line. Assuming that the code is correct then there must be some other reason.

Sub variables()
   'Declaring variables
   Dim last_name As String, first_name As String, age As Integer, row_number As Integer

   'Variable values
   row_number = Range("F5") + 1
   last_name = Cells(row_number, 1)
   first_name = Cells(row_number, 2)
   age = Cells(row_number, 3)
   'the above is highlighted to show error

   'Dialog box
   MsgBox last_name & " " & first_name & ", " & age & " years old"

End Sub

I am really keen to proceed with this course.

Mark

Bonjour

Quel est la description de l'erreur ?

Vérifies bien le contenu de la colonne C

Ton fichier serait souhaitable


Traduction automatique machine translation

[b]Hello

What is the description of the error?

Checked out the contents of column C

Your file would be desirable

Modified your code[/b]

Sub variables()
   'Declaring variables
  Dim last_name As String, first_name As String, age, row_number As Integer

Ce qui m'etonne dans ce code est plutot la partie:

row_number = Range("F5") + 1

row_number est un integer et Range("F5") est sense etre une cellule.

La macro ne devrait pas trouver un probleme a ce niveau?

english version:

In your macro you try to add a cell to a number

row_number = Range("F5") + 1  ' int = cell + 1 ...

I find it strange that your macro doesn't bug here

Hello,

where is the problem?

please join your workbook without confidential data.

then we can help you.

Rechercher des sujets similaires à "vba course variables"