I am not a fan of using "Active" family commands. Because of this type of problem that may or may not occur.
Do
If Not (IsEmpty(ActiveCell)) Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
You can sub-post for:
Range("D5").End(xldown).offset(1,0)
And so use directly because this is a command and not loop.
Range("D5").End(xldown).offset(1,0).Value = Me.ComboBoxNOME.Value
with Range("D5").End(xldown).offset(1,0)
.Offset(0, 1).Value = Me.TextBoxSALDO.Value * MULTIPLICAR
.Offset(0, 2).Value = Me.TextBoxDEBITO.Value * MULTIPLICAR
.Offset(0, 3).Value = Me.TextBoxGARANTIA.Value * MULTIPLICAR
.Offset(0, 5).Value = Me.TextBoxPLANO.Value * MULTIPLICAR
end with
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[Answering your questions]
"... and this code it will not overwrite the data when I open the
form a second time for example?"
No, this code I mentioned shouldn’t overlap anything. Just like the original it looks for the last line and then fills the bottom line with the summarizing information will always adc. a new data line.
"...but is giving error in this code yours, something returns me saying that
by the = (equal) The error goes to this line ->
Range("D5"). End(xldown). offset(1,0) Could check for me by
favour..."
Strange that you gave me this error could you share the file with sample information for me to take a look at and help? But I noticed that there is a logical error on my part in this code that I gave you. In this case this part:
Range("D5").End(xldown).offset(1,0).Value = Me.ComboBoxNOME.Value
with Range("D5").End(xldown).offset(1,0)
.Offset(0, 1).Value = Me.TextBoxSALDO.Value * MULTIPLICAR
.Offset(0, 2).Value = Me.TextBoxDEBITO.Value * MULTIPLICAR
.Offset(0, 3).Value = Me.TextBoxGARANTIA.Value * MULTIPLICAR
.Offset(0, 5).Value = Me.TextBoxPLANO.Value * MULTIPLICAR
end with
It would be better this way:
with Range("D5").End(xldown).offset(1,0)
.Value = Me.ComboBoxNOME.Value
.Offset(0, 1).Value = Me.TextBoxSALDO.Value * MULTIPLICAR
.Offset(0, 2).Value = Me.TextBoxDEBITO.Value * MULTIPLICAR
.Offset(0, 3).Value = Me.TextBoxGARANTIA.Value * MULTIPLICAR
.Offset(0, 5).Value = Me.TextBoxPLANO.Value * MULTIPLICAR
end with
Note that I took the line code:
Range("D5").End(xldown).offset(1,0).Value = Me.ComboBoxNOME.Value
And put it next to the With
with Range("D5").End(xldown).offset(1,0)
.Value = Me.ComboBoxNOME.Value 'ESTA LINHA
I tested here as the example below and this "ok"
Apparently your code contains no errors. It would be easier to identify directly in your spreadsheet.
– Antonio Santos
@Antoniosantos here is the complete project: https://drive.google.com/open?id=15hgrZS4DhhkexYtom-x7B_uLAD0uM4Fy I hope you can help me friend, I thank you already.
– Magno
Unfortunately it is working with me. Saved without errors.
– Antonio Santos
Create a [mcve] with a table with the value it contains in the cell. What is in
ActiveCell
?– danieltakeshi