LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unique problem with recorded macro


I seem to have a "unique" problem. I have researched many differen
sites about VBA and macros, etc. ... but, none have seemed to run int
this situation.

In short, I recorded a macro to do the following: (1) select a name
region, (2) unprotect the worksheet, (3) sort the named region (b
last name, then first name), (4) protect the worksheet.

Then, I turn right around and run the macro--it does steps (1) and (2
just fine, but pauses on step (3) [Note: sometimes it does (3) the
stops, and other times it doesn't even do step (3)]

I have looked at the VBA code, and it was the same code that worke
with earlier versions of my workbook--believe me, I have re-recorde
this same macro many times--the sort works when I record it, but alway
pauses (usually before) it does the sort. [In fact, the data sor
ALWAYS works when I do it in Excel, but has problems with the VB
code.]

Even when I use the Debug toolbar to step through the code--i
highlights each step in yellow, and then runs it--but when it gets t
the sort step, the debugger will not go beyond the sort step. In fact
it will attempt running the sort (not always succeeding) and put th
cursor before the sort statement.

Needless to say, I'm frustrated! Any help will be appreciated!

Here is the VBA code, in case it helps:
Sub sort_name()
Application.Goto Reference:="student.sort"
ActiveSheet.Unprotect
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending
Key2:=Range("B4") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1
MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
DataOption2:= _
xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True _
, AllowSorting:=True
Range("A1").Select
End Su

--
Junio
-----------------------------------------------------------------------
Junior's Profile: http://www.msusenet.com/member.php?userid=515
View this thread: http://www.msusenet.com/t-187106295

 
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Recorded macro Gaurav[_3_] Excel Discussion (Misc queries) 4 September 22nd 08 06:46 PM
Problem with a recorded macro to create two pivot tables from same data rjamison Excel Programming 0 June 14th 05 12:14 AM
Problem with a recorded macro to create two pivot tables from same data Pete Straman via OfficeKB.com[_2_] Excel Programming 1 April 20th 05 05:28 PM
Problem with my Unique Number Macro...Help? RPIJG[_16_] Excel Programming 2 May 14th 04 01:38 AM


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

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

About Us

"It's about Microsoft Excel"