PDA

View Full Version : export worksheet problem



prasadksu
04-03-2009, 10:48 AM
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

Private Sub CommandButton1_Click()

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

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

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


End Sub

Private Sub CommandButton2_Click()

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

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

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

End Sub

Bob Phillips
04-03-2009, 11:50 AM
Try selectin the sheets then the columns in separate actions.