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
Solved

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

Posted on 2014-11-26
4
129 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
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 46

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

My experience with Windows 10 over a one year period and suggestions for smooth operation
Outlook Free & Paid Tools
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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