Visual Basic Programming in Excel

Asked

Viewed 938 times

2

Using Visual Basic Excel mode, I am creating a customer registration form. It has a button called "new". On this button it would add a value to the Code field that is in the excel spreadsheet. However, when I test it presents the following message:

Runtime error '9': Subscribed out of range

And when I click on debug, it points to the following line of code as 'wrong'':

Do Until Sheets("CLIENTES").Cells(linha, 1) = ""

What should I do to solve this problem?

  • 2

    What is the value of linha? Hover over variable while debugging

1 answer

2

What was missing was you referencing what you wanted from the cells, he is not able to understand why the error.

The correct thing would be to use the following:

Do Until Sheets("CLIENTES").Cells(linha, 1).Value = ""
'faz alguma coisa
Loop

So you will be stating that you want to take the value of the Cell(line, 1) that is in the Spreadsheet("Clients")

Browser other questions tagged

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