Find last available row in a range of cells

SSF1590

Board Regular
Joined
Oct 20, 2019
Messages
73
Hello,

I am looking to make a code work in the way that it finds the last available empty row in columns A to L since M will have data pull with a formula. But I am not sure how to or where to add the range to make it work. Can I please ave your help?

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PCARDatabase")


iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1




If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
Exit Sub


End If


With ws
' .Unprotect Password:="password"
.Cells(iRow, 1).Value = Me.TextBox1.Value
.Cells(iRow, 2).Value = Me.TextBox17.Value
.Cells(iRow, 3).Value = Me.ComboBox2.Value
.Cells(iRow, 4).Value = Me.TextBox2.Value
.Cells(iRow, 5).Value = Me.TextBox3.Value
.Cells(iRow, 6).Value = Me.TextBox4.Value
.Cells(iRow, 7).Value = Me.TextBox5.Value
.Cells(iRow, 8).Value = Me.TextBox6.Value
.Cells(iRow, 9).Value = Me.TextBox8.Value
.Cells(iRow, 10).Value = Me.TextBox9.Value
.Cells(iRow, 11).Value = Me.TextBox10.Value
.Cells(iRow, 12).Value = Me.ComboBox1.Value
' .Protect Password:="password"

Thank you.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
For me it's working right, the range is mentioned in ws.Cells
Did you check iRow value ??
 
Upvote 0
Try
Code:
ws.range("A:L").Find(What:="*"
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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