View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Continuing problem populating userform from a previous record

You have to tell Excel what a range is referring to before you use it.
The With statement has to come after the Set statement.
The "With lastrow" and "End With" should be removed...
'----------------------
With lastrow
Set lastrow = Cells(y, 1)
' .End(xlToLeft)
End With
'----------------------
Looks like your spell checker isn't working either.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Dooley007"
wrote in message
I have written a programme to find a previous record in my database
(presently on 35 records but will eventually grow to about 1500
records).
-snip-
Once the program goes to "Userform4.show" I want to be able to pull
information from the record and plucg it back into the userform4.
Here is the code for the Userform4.

Private Sub UserForm_Initialize()
Dim Ts, Lu, y, i As Integer
Dim x As String
Dim st As String
Dim lastrow As Range
ActiveWorkbook.Sheets(1).Activate
st = Selection.Address

With lastrow
Set lastrow = Cells(y, 1)
' .End(xlToLeft)
End With

' Set lastrow = Range(x)
' y = Cells(i, 1).row
' textbox.Text =
-snip-
End Sub

Theprogram generates an error message
"Run time error '1004'
Application - defined or object-defined error"
at the point "Set lastrow = Cells(y, 1)".
I have tried several different fixes but an error still occors.
Anyone got any ideas? This is driving me nuts.
Dooley007