Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default programming a button

I created a macro that will select specific columns on different sheets and
sort them, and it works fine. I want to create a command button that will do
the same thing, I copied the code from the macro and put into the button and
I get an error when it tries to select the columns. What do I need to change
to make this work? here is the code I have

Columns("A:E").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default programming a button

Don't select

With Worksheets("Sheet2")
.Columns("A:E").Sort Key1:=.Range("B2"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pappaz" wrote in message
...
I created a macro that will select specific columns on different sheets and
sort them, and it works fine. I want to create a command button that will
do
the same thing, I copied the code from the macro and put into the button
and
I get an error when it tries to select the columns. What do I need to
change
to make this work? here is the code I have

Columns("A:E").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default programming a button

Bob,
Thank You very much, it does exactly what I wanted now.

-Mike

"Bob Phillips" wrote:

Don't select

With Worksheets("Sheet2")
.Columns("A:E").Sort Key1:=.Range("B2"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pappaz" wrote in message
...
I created a macro that will select specific columns on different sheets and
sort them, and it works fine. I want to create a command button that will
do
the same thing, I copied the code from the macro and put into the button
and
I get an error when it tries to select the columns. What do I need to
change
to make this work? here is the code I have

Columns("A:E").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
programming button again Hendri Adriaens Excel Programming 5 February 14th 07 11:37 AM
programming button Mike Excel Programming 8 February 13th 07 10:51 PM
Button: ActiveX programming nicolascap[_4_] Excel Programming 1 March 14th 06 08:13 AM
Programming for a save button Candee[_23_] Excel Programming 5 May 25th 04 08:23 PM
Programming behind a button DRE Excel Programming 2 July 18th 03 03:40 PM


All times are GMT +1. The time now is 03:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"