+ Reply to Thread
Results 1 to 3 of 3

Trying to Export Data to another Worksheet with Button

  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    2

    Trying to Export Data to another Worksheet with Button

    Good Afternoon Everyone!

    I am having some troubles with this piece of code for exporting data from one worksheet to another. I have an activeXbutton that exports data from one sheet and store it in another. My goal was to be able to export 10-20 rows of data for analyzing but this macro isn't exactly doing that. It will export two rows of data and then keep overwriting the second row. Some help on what I am doing wrong would be greatly appreciated.

    Private Sub CommandButton1_Click()

    Dim Material As String, Types As String, Diameter As String, Flow As String, Regime As String, TotalLossesm As String, TotalLossespsi As String

    Worksheets("Hydraulics").Select
    Material = Range("C10")
    Types = Range("C11")
    Diameter = Range("C12")
    Flow = Range("C15")
    Regime = Range("I9")
    TotalLossesm = Range("I15")
    TotalLossespsi = Range("I17")
    Worksheets("Results").Select
    Worksheets("Results").Range("A10").Select
    If Worksheets("Results").Range("A10").Offset(1, 0) <> "" Then
    Worksheets("Results").Range("A10").End(xlDown).Select
    End If
    ActiveCell.Offset(1, 0).Select
    ActiveCell.Value = Material
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Types
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Diameter
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Flow
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Regime
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = TotalLossesm
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = TotalLossespsi
    Worksheets("Hydraulics").Select
    Worksheets("Hydraulics").Range("C10").Select


    End Sub

    Thanks,
    njr

  2. #2
    Registered User
    Join Date
    12-15-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    1

    Re: Trying to Export Data to another Worksheet with Button

    It overwrites the second row because you told it to.
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Types
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Diameter
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Flow
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = Regime
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Value = TotalLossesm
    ActiveCell.Offset(0, 1).Select

    try (1, 1) and it should write to row 1 col 1.
    (2, 2) etc....

  3. #3
    Registered User
    Join Date
    12-15-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    2

    Re: Trying to Export Data to another Worksheet with Button

    Thanks. I found my error and it's working now as intended.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto-export worksheet to form fillable PDF using a macro button
    By smtasci in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2014, 05:18 PM
  2. [SOLVED] How to use a Macro submit button to export results to another worksheet
    By EscargotMyCargo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-21-2013, 07:51 AM
  3. Master button to filter all records in ONE worksheet and export to new workbook
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2011, 02:05 PM
  4. Export data from Excel to Word doc using button
    By starkjr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-13-2010, 11:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1