to find the LastRow

jdcar

New Member
Joined
Oct 9, 2021
Messages
17
Office Version
  1. 2016
Platform
  1. Windows
Hi Everyone
I have a form that has a combobox for choosing the subject, I use "labels" to show that data and a command to regist it in the worksheet
It turns out that the last line is not identified, so the information to be added is superimposed on the previously registered information. How to overcome?
I enclose an excerpt of code.
Thanks you.
VBA Code:
Private Sub CommandButton2_Click()
Dim wks As Worksheet
Dim additem As Range
Dim rng As Range

Set wks = Sheet5
   Set rng = Worksheets("sheet5").Cells(Rows.Count, "a").End(xlUp).Offset(1, 0)

rng.Offset(0, 1) = Label1.Caption
rng.Offset(0, 2) = Label2.Caption
rng.Offset(0, 3) = Label3.Caption
.....
 
Hi everyone
I thank all those involved in the debate of ideas, especially to Fluff intervention, the first one to attend me towards the resolution of this problem raised.
I was a little confused for a little experienced, like me, in vba, however I made several tries/errors, and I think I have solved my problem.
I proceeded to add in an extra data in column "A" of the spreadsheet and so the system worked.
Was it because, in the spreadsheet, I begun to enter data from column "B", the reason why it didn't work?
If this is the reason for the non-functioning and if I am not abusing your good will, I would appreciate information for the cases starting in column "B" how to do it?
Thank you very much.
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Was it because, in the spreadsheet, I begun to enter data from column "B", the reason why it didn't work?
Yes it probably was.
If this is the reason for the non-functioning and if I am not abusing your good will, I would appreciate information for the cases starting in column "B" how to do it?
That's what the code I posted in post#2 does. ;)
It determines the last used row in col B whereas your code was looking at col A.
 
Upvote 0
Yes it probably was.

That's what the code I posted in post#2 does. ;)
It determines the last used row in col B whereas your code was looking at col A.
Hi Fluff
Many, many thanks for all information.
Best regards
Jdcar
 
Upvote 0

Forum statistics

Threads
1,224,875
Messages
6,181,516
Members
453,050
Latest member
Obil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top