Solved

How can I export data from a VBA Userform to Excel?

Posted on 2014-11-26
4
141 Views
Last Modified: 2014-12-23
I have the following code to export some data values from a Userform to Excel.

Private Sub ExportCommandButton_Click()

'Determine next empty row in the Analysis worksheet
Dim erow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
erow = ws.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row

'Transfer information from Text and Combo Boxes
ws.Cells(erow, 1) = ItemNumberTextBox.Value
ws.Cells(erow, 2) = cboMachType.Value
ws.Cells(erow, 3) = SetupTimeTextBox.Value
ws.Cells(erow, 4) = CycleTimeTextBox.Value
ws.Cells(erow, 8) = GroupNumberTextBox.Value

'Transfer information from Option Buttons
If MachineStatusOptionButton1 = True Then ws.Cells(erow, 5) = "1"
If MachineStatusOptionButton2 = True Then ws.Cells(erow, 6) = "1"
If MachineStatusOptionButton3 = True Then ws.Cells(erow, 7) = "1"

End Sub

Open in new window


I am getting an "application-defined or Object-defined error" pointing towared this row.
erow = ws.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row

Open in new window


What am I doing wrong?
0
Comment
Question by:Nugget1224
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40467005
It's very subtle.

You've got x1Up (X - number 1 - U - P)

Instead, you should have xlUp (X - L - U - P)
0
 

Author Comment

by:Nugget1224
ID: 40467036
Thank you. That is infuriatingly simple.
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40514585
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question