Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VBA code sort problems - recorded macro does not work with userform

Hi

I need to sort a range of cells to put in numerical order. I recorded a
macro but when I transfered it to my userform button I hit problems

The following code sorts but I get a runtime error 13 type mismatch when I
exit the userform.
When I debug it has failed when it should be loading another userform

Sub Mysort1()

Sheets("Lists").Select
Range("CM38:CM42").Select
Selection.Sort Key1:=Range("CM38"), Order1:=xlAscending, Header:=xlGuess
_
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

I tried removing the selection part and used

Sheets("Lists").Range("CM38:CM42").Sort Key1:=Range("CM38"),
Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

This time sorting does not take place and I get runtime 1004
The sort reference is not valid. Make sure that it's within the data you
want to sort, and the first SortBy box isn't the same or blank

I have searched the web but have not found a solution

Can anyone see what I am doing wrong.

Kenny
XP pro and office 2003


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
Recorded Macro Problems GraemeH Excel Worksheet Functions 1 December 6th 10 10:02 AM
Programed sort generates error: originated as recorded macro plh Excel Programming 2 October 31st 07 05:43 PM
Newbie-question: recorded macro does not work - why? Michael Moser Excel Programming 3 June 14th 06 07:11 PM
looking to simplify a recorded macro with code HM Excel Programming 2 February 10th 04 06:35 PM
flip an autoshape using VBA- recorded macro doesn't work Keith R[_3_] Excel Programming 0 October 23rd 03 08:32 PM


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

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"