Consulting

Results 1 to 2 of 2

Thread: export worksheet problem

  1. #1

    Post export worksheet problem

    Hello all,

    I am trying to export two worksheets separately to two seperate workbooks and to a known location on clicking two seperate buttons (commandbutton1 and command button 2) on userform. The code that I used is given below. When I click on the first button it saves fine while it also changes the name of the working excel workbook to the name that i saved the first worksheet. Then if I try the next one I get the error "select method of Range class failed". Can anyone help me out with the right code to export two seperate sheets to a known location.


    Any help would be greatly appreciated.

    Thanks,
    Prasad

    The code I used

    [VBA]Private Sub CommandButton1_Click()

    Sheets("AvganHRU").Columns("B").Select
    Selection.NumberFormat = "0.00"

    Sheets("AvganHRU").Columns("A").Select

    Application.Dialogs(xlDialogSaveAs).Show ("D:\deleteme\")


    End Sub

    Private Sub CommandButton2_Click()

    Sheets("AvganSUB").Columns("B").Select
    Selection.NumberFormat = "0.00"

    Sheets("AvganSUB").Columns("A").Select

    Application.Dialogs(xlDialogSaveAs).Show ("D:\deleteme\")

    End Sub[/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try selectin the sheets then the columns in separate actions.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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