last row problem

polboy_mx

New Member
Joined
Oct 7, 2004
Messages
33
hello to all, i have one useform to capture data but I cannot locate "lastrow"
this its the code...
Private Sub btn_prodxklienteOK_Click()
Dim LastRow As Long

LastRow = Worksheets("pxk").Range("A65536").End(xlUp).Row + 1
**here begin the problem
Cells(LastRow, 1).Value = tb_idkliente.Value
Cells(LastRow, 2).Value = cb_kliente.Value
Cells(LastRow, 3).Value = cb_artikulos.Value
Cells(LastRow, 4).Value = tb_cantidad.Value
Cells(LastRow, 5).Value = tb_dolar.Value
Cells(LastRow, 6).Value = tb_pesos.Value
Cells(LastRow, 7).Value = Calendar1.Value
Cells(LastRow, 8).Value = tb_factura.Value
Unload Me
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
What is the actual problem?

The posted code looks fine to me.

Is it not returning the expected last row or is it producing errors?
 
Upvote 0
I don't see anything wrong with that code. Are you getting an error of some sort when you try to run it? How is it not working for you?
 
Upvote 0
I've never used the Range.End.Row before so I don't know how that works, but I usually use:
LastRow = ActiveSheet.UsedRange.Rows.Count
 
Upvote 0
polboy:

I looked at your workbook. The form does not have a textbox named tb_idkliente. That is causing the error. It can not update the value since the item does not exist.

You will also have a problem with this line:
Code:
Cells(LastRow, 7).Value = Calendar1.Value
You do not have an object called Calendar1. You should use DTPicker1 instead.
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,636
Members
452,662
Latest member
Aman1997

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