Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Transferring Data from a UserForm to a worksheet

Helo all. I have been using examples to create a Userform to enter data
into a worksheet. Although I have followed the instruction (with some
name changes) I keep getting a subscript out of range error in Line 4
Set ws = worksheets.
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("BrickData")

iRow = ws.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row

If Trim(Me.TxtType.Value) = "" Then
Me.TxtType.SetFocus
MsgBox "Please Enter a Brick Type"
Exit Sub
End If

ws.Cells(iRow, 1).Value = Me.TxtType.Value
ws.Cells(iRow, 2).Value = Me.TxtShape.Value
ws.Cells(iRow, 3).Value = Me.TxtOrder.Value
ws.Cells(iRow, 4).Value = Me.TxtDate.Value
ws.Cells(iRow, 5).Value = Me.TxtQuantity.Value

Me.TxtType.Value = ""
Me.TxtShape.Value = ""
Me.TxtOrder.Value = ""
Me.TxtDate.Value = ""
Me.TxtQuantity.Value = ""

End Sub
Any Ideas? Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Transferring Data from a UserForm to a worksheet

subscript out of range would mean you don't have a sheet with the name
BrickData

check the name of your sheet and make sure you don't have extra spaces on
the end or you haven't misspelled it in your code.

--
Regards,
Tom Ogilvy



"Kezza" wrote:

Helo all. I have been using examples to create a Userform to enter data
into a worksheet. Although I have followed the instruction (with some
name changes) I keep getting a subscript out of range error in Line 4
Set ws = worksheets.
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("BrickData")

iRow = ws.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row

If Trim(Me.TxtType.Value) = "" Then
Me.TxtType.SetFocus
MsgBox "Please Enter a Brick Type"
Exit Sub
End If

ws.Cells(iRow, 1).Value = Me.TxtType.Value
ws.Cells(iRow, 2).Value = Me.TxtShape.Value
ws.Cells(iRow, 3).Value = Me.TxtOrder.Value
ws.Cells(iRow, 4).Value = Me.TxtDate.Value
ws.Cells(iRow, 5).Value = Me.TxtQuantity.Value

Me.TxtType.Value = ""
Me.TxtShape.Value = ""
Me.TxtOrder.Value = ""
Me.TxtDate.Value = ""
Me.TxtQuantity.Value = ""

End Sub
Any Ideas? Thanks in advance


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transferring CERTAIN Data from one worksheet to another Samantha Excel Worksheet Functions 1 May 7th 09 10:54 PM
Transferring data from one worksheet to another Amedea_C Excel Discussion (Misc queries) 0 August 12th 08 02:16 PM
Transferring chart data from one worksheet to another DaddyO Charts and Charting in Excel 1 April 27th 07 01:13 PM
Transferring data from one worksheet or workbook to another Janine Excel Worksheet Functions 5 September 5th 06 05:15 PM
transferring multiline text from userform to worksheet - line break problem Paul Excel Programming 6 May 8th 05 03:21 AM


All times are GMT +1. The time now is 01:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"