VBA problem #2

Can anybody tell me why variable g is causing an error when it gets to 
order1:=g?  Why wouldn't d be causing the same error?  Thanks!

d = InputBox("What cell do you want to sort by on this page?", Xpos:=9000, 
Ypos:=7000)
g = InputBox("How do you want to sort?  Please answer either" & Chr(13) & _
"with xlAscending or xlDescending", Xpos:=9000, Ypos:=7000)
    
    If d = "" Then
        GoTo Option1
    End If
    
    On Error GoTo Option2
    
    ActiveSheet.Range(a, c).EntireRow.Select
    Selection.Sort Key1:=Range(d), order1:=g
0
Mark11 (22)
1/26/2005 2:13:01 PM
excel.misc 78881 articles. 5 followers. Follow

2 Replies
386 Views

Similar Articles

[PageSpeed] 38

Because the sort order expects a long value of 1 or 2. xlAscending and
xlDescending are Excel constants that evaluate top 1 or 2. You cannot use a
string with xlAscending or xlDescending in the Sort function, you need to
decode to 1 or 2.

Maybe

        Selection.Sort Key1:=Range(d), order1:=IIf(LCase(g) = "xlascending",
1, 2)

HTH

RP
(remove nothere from the email address if mailing direct)


"Mark1" <Mark1@discussions.microsoft.com> wrote in message
news:E884C6DA-6F69-437C-AD39-D2F30BBD45F3@microsoft.com...
> Can anybody tell me why variable g is causing an error when it gets to
> order1:=g?  Why wouldn't d be causing the same error?  Thanks!
>
> d = InputBox("What cell do you want to sort by on this page?", Xpos:=9000,
> Ypos:=7000)
> g = InputBox("How do you want to sort?  Please answer either" & Chr(13) &
_
> "with xlAscending or xlDescending", Xpos:=9000, Ypos:=7000)
>
>     If d = "" Then
>         GoTo Option1
>     End If
>
>     On Error GoTo Option2
>
>     ActiveSheet.Range(a, c).EntireRow.Select
>     Selection.Sort Key1:=Range(d), order1:=g


0
bob.phillips1 (6510)
1/26/2005 2:25:47 PM
Mark1,

You aren't really using xlAscending and xlDescending, which are defined
constants. You are using strings instead, which aren't really the same
thing:  "xlAscending"  does not equal  xlAscending

Instead, use soemthing like:

Dim g As Variant
g = MsgBox("Click Yes for Ascending and No for Descending", vbYesNo)

Then in the sort, use:

Order1:=IIf(g = vbYes, xlAscending, xlDescending)

HTH,
Bernie
MS Excel MVP

"Mark1" <Mark1@discussions.microsoft.com> wrote in message
news:E884C6DA-6F69-437C-AD39-D2F30BBD45F3@microsoft.com...
> Can anybody tell me why variable g is causing an error when it gets to
> order1:=g?  Why wouldn't d be causing the same error?  Thanks!
>
> d = InputBox("What cell do you want to sort by on this page?", Xpos:=9000,
> Ypos:=7000)
> g = InputBox("How do you want to sort?  Please answer either" & Chr(13) &
_
> "with xlAscending or xlDescending", Xpos:=9000, Ypos:=7000)
>
>     If d = "" Then
>         GoTo Option1
>     End If
>
>     On Error GoTo Option2
>
>     ActiveSheet.Range(a, c).EntireRow.Select
>     Selection.Sort Key1:=Range(d), order1:=g


0
Bernie
1/26/2005 2:30:57 PM
Reply:

Similar Artilces:

Problem to open excel file
Hi to all, I have a problem with all excel file. The user can't open all excel file when she did a double click on it. She has this error message : "cannot find the file 'c:\documents and settings\desktop\......test.xls' (or one of its components). Make sure the path and filename are correct. And that all required libraries are available" Do you know what can I do to solve the issue?? regards Malcolm Your Excel file association may be lost. Start>Run "excel.exe /regserver"(no quotes and note the space before the / mark). You may have to en...

Linq, aggregate Sum problem
Hi, I figured out that I am unable to query for an aggregate function (Sum) over a column I have properly filled. The following NUnit test method will fail due to a NULL value even i think this should not be true: Provisionsabrechnung.UnitTests.Provisionsrechner.Test_Aggregate_Sum_with_Null: System.InvalidOperationException : Das Objekt mit Nullwert muss einen Wert haben. public void Test_Aggregate_Sum_with_Null() { ProvisionsabrechnungDataContext dataContext = new ProvisionsabrechnungDataContext(); Objektverkauf o1 = new Objektverk...

Crazy Sorting Problem.....
Ok so I have colums A though D that need to line up with E through P. I have a common symbol in D and F. I need to get rid of everything in colum A through D that does not line up with the E through P useing the common symbol as a referance. I am right now deleting extra info by hand. Please help. Hi see your other post -- Regards Frank Kabel Frankfurt, Germany Neal wrote: > Ok so I have colums A though D that need to line up with E through P. > I have a common symbol in D and F. I need to get rid of everything in > colum A through D that does not line up with the E through P ...

WaitForSingleObject Problem
Hi all, I use WaitForSingleObject(hProcess, INFINITE) to wait for execution of the MS ActiveX Control Pad Setup (started out of my application). <code> CreateProcess(NULL, "setuppad.exe", NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &startupInfo, &processInfo) WaitForSingleObject(processInfo.hProcess, INFINITE) DoSomethingElse </code> At the beginning of installation everything is fine, but after a little bit of time, the CPU usage is 50% and nothing is going on (it's after searching for installed components). When I don't use WaitForSingleOb...

Problem Syncronizing.
HI, I have problems with a syncronized store that I had to syncronize again from the beginning. Give me alot of TIme out when I use the 401 Worksheet. Since some of the data is in the HQ Database I would like to know if there any operation I can do so then tell to the HQ client that I just want to upload some information?. Thanks in advance for your help. Rgds Rodrigo Go to Manager, Help, About. If your version is 1.2.0151 you have a version that won't work with Global Customer turned on. Contact MBS and ask for a Hot Fix to address this issue. Install the Hot Fix on all PC...

INSERT INTO problems
Hi all, I hope this doesn't appear twice, I did it a while ago and it never came up! So here goes again! I am trying to use INSERT INTO to insert one record in to a table (tna feedback) in two fields (USER ID: and DESK/LAPTOP). The values are generated by two different forms; stUser comes from this form and stMachine comes from another form which has been hidden once the user has chosen the value. This part works fine. However, every time I run it I get an "Incomplete Query clause" error message but can't fidure out what I've done wrong! Here is the code: Dim SQL ...

Access 2000 Package and Deployment Wizard problem!
I have created an Access 2000 application that I now wish to distribute to users as an MDE file. The Access 2000 Package and Deployment Wizard does a fine job of storing the relevant installation files on a CD, exploiting A2K Runtime. However, I would prefer to let users download my application from a website. The Package and Deployment Wizard offers a 'Web Publishing' deployment option that appears to address this need. My only problem is that it doesn't work for me. I get the following error message, Unexpected error number 48 has occurred: File not found: WebPost.dll I...

Process all cells in a (user) selection
I am using this code to give me cell by cell access to a code defined selection; Dim aCell As Range For Each aCell In Sheet4.Range("A4:A34") ' Do Stuff Here Next aCell which processes every cell in the A4:A34 Range How do I do the same thing for a selection drawn by the user before pressing my 'Process' button ? Thanks On 05 May 2010 11:10:21 GMT, Isis <isissoft@NOSPAMbtinternet.com> wrote: >I am using this code to give me cell by cell access to a code defined >selection; > >Dim aCell As Range >For Each aCell In S...

Microsoft Money Deluxe 2004 #2
How do I install on a drive other than C? I am running Windows XP Home Edition. In microsoft.public.money, Don wrote: >How do I install on a drive other than C? I am running Windows XP Home >Edition. Early in the install process, Money has a place to click to change where the installation is to take place. If you install in a drive other than the system drive, there could be an issue. I was thinking there might be, but I don't find a reference. http://support.microsoft.com/kb/79917/en-us implies that should work. There is no problem. I have always installed Money (from M...

Outlook startup #2
All of a sudden all our outlook client (Outlook2002/Exchange 2000) are getting the following message: "Your microsoft exchange server is unavailable" with the retry and cancel options. We hit the retry option it connects to the exchange. Any ideas???? Sounds like name resolution problems. Can you ping the Exchange server, by name, from the affected workstations? -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP http://home.hawaii.rr.com/schorr **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup....

Count problems[Excel 97]
Hi there, I did a search on the forum to find an answer to my question but didn' find anything. Here is my prob : Lets say I got this page-> ___a___b_____c__d__ 1 Name Type Job bla 2 Name Type Job bla 3 Name Type Job bla 4 Name Type Job bla 5 Name Type Job bob I want a Cell to write how many row I got( 5 in this exemple) and onl count the cells with bla in the D column(4 in this exemple). Sorry if I'm not really clear but if you can help me feel free t answer :) thx, Tulkas -- Tulka -----------------------------------------------------------...

Problems with german characters (umlaute)
Hello colleagues, it happes every months that a mail reaches us with I don't know how coded german characters. Our german customers are calling us, asking what we're missing on our system. I've checked one of these mails and the only thing I found out that the codepage, which was specified in the header, was the same than in the other mails I've in my mailbox and which I can read perfectly. The strange thing in current case is, that the email is displayed correctly when the mail is opened in Outlook Web Access. I need some help how to get hand on these problems. Many...

VBA- Application.Wait?
Does PowerPoint not have "Application.Wait" like Excel? Is there another way to pause code for a few seconds in PPT 2003/2007 while a small bat file runs? -Mel On 3/10/10 2:29 AM, Mel wrote: > Does PowerPoint not have "Application.Wait" like Excel? Is there > another way to pause code for a few seconds in PPT 2003/2007 while a > small bat file runs? > > -Mel From Example 8.4 on my Web site (http://www.PowerfulPowerPoint.com/): Sub Wait() waitTime = 5 Start = Timer While Timer < Start + waitTime DoEvents ...

NO #2
Seriously Microsoft, what the fuck? I'm not saying this as some sort of mac fan or money zealot or whatever. Hell, I even worked for you once... but.. YOU ARE DEAD TO ME! Fine, stop selling Money, I don't care. BUT LEAVE YOUR GOD DAMNED SERVERS UP SO WE CAN GET ONLINE UPDATES INDEFINITELY. How much could that cost you a month? A couple thou? You throw more than that away every second repairing peoples broken Xbox 360s. This is a new freakin low. Seriously. ...

Moving Email Domain off of Exchange #2
Good afternoon, I am in the process of moving one of our clients off of our Exchange server and on to a third party email host. I have removed there domain from the default recepient policy, and also disabled and unattached or deleted their mailboxes. I have repointed there MX record to point to the new host etc. The problem is when I try to email them from our network my exchange server still thinks it is responsible for handling the mail for the domain and does not try to send it out of the domain. I get a 5.1.1 e-mail account does not exist in this organization. How do I let Exchange ...

Combine 2 rows if name is same in Column B & C on both
Combine 2 rows if name is same in Column B & C on both 2 spreadsheets - Sheet 1 is bigger with extra names in column B & C Lastname Firstname Both - Column B & C Lastname Firstname - both sheets Sheet 1 has data in Col. D & E Sheet 2 has data in Col. F & G Sheet 1 has extra names not in Sheet 2 If Sheet 1 B&C = Sheet 2 B&C , then add F&G columns from sheet 2 , behind D& E columns on sheet 1 , for the match of names in Column B & C Thanks kerns.walter@epa.gov On Nov 13, 12:50 pm, wk <kerns.wal...@epa.gov> wrote: > Combine 2 rows if name...

SDK for Microsoft POS 2.0
Does anyone know of an SDK for MS POS 2.0? I have noticed several companies making add-ons for modules for MS POS, are they standalone products that integrate with the POS database or are they actually integrated into the MS POS itself? Thanks for your comments. On Nov 22, 4:46=A0am, NetKnight <NetKni...@discussions.microsoft.com> wrote: > Does anyone know of an SDK for MS POS 2.0? > Thanks for your comments. they are standalone products integrated with the database, and also add-on integrated with SO POS/SO Manager via COM antonio ...

View both incoming/outgoing messages by Thread or Conversation ? #2
Is it possible to view messages in outlook 2003 by Thread or Conversation, both incoming and outgoing, in a single folder, or Inbox, just like Outlook Express News Reader. For example: + Sent Message + Received Reply +Sent Message or Replied + Received Reply I tried using Arrange by Conversation Option in outlook 2003 Inbox Folder, but its just showing Inbox Messages, not Sent Items Messages. Best Regards, Luqman ...

countif problem.
I wrote a formula in a cell that contains the following: =countif(f5:f268,"> char(32)") / countif(e5:e268,"> char(32)") I have verified that any unused cells have blanks spaces in them. Both columns have data in the same rows so the counted value for each column should be the same but it isnt. All cells contain only numbers or letters and the cells format is general. Any suggestions?? Not sure I get it, but try =countif(f5:f268,">"&char(32)) / countif(e5:e268,">"&char(32)) "psion" <oregonsparkie@hotmail.com> w...

Compile Error in hidden module: Autoexec #2
I need help when ever I opepen or close any office product ( excel , word etc...) I get the message shown above.... How do I fix it please help ag Take a look at this: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q307410 HTH Anders Silven "Ash" <ashrafg@sympatico.ca> skrev i meddelandet news:1574f01c446a0$4b5db2c0$a501280a@phx.gbl... > I need help when ever I opepen or close any office > product ( excel , word etc...) I get the message shown > above.... How do I fix it please help > > ag ...

Carriage Return/Line Feed Problem
Hi guys, I wrote some code that gets the HTML from a Web page and stores it in a buffer, then I display the buffer in a big multiline CEdit box. The problem is that on many pages I don't get new lines, I just get a thick solid verticle line kinda like this: || where it should return. Also, if I view the pages (view source) in Notepad they look fine. Most pages do that, but interestingly Microsoft pages do the proper new line and look great in my edit box. Maybe I have to replace all the \r with \r\n or something like that ? Does a \r\n still only take up 1 char ? I download the page in...

Publisher 2003 files try to open in Publisher 97 #2
Back again, but with a different Pub 2003/Pub97 issue Have Office 2003 with Publisher 2003 and Publisher 97 both on my XP Pro system Recently I find that files created in Pub 2003 are being saved as files with the Pub 97 Logo, and when you try to open them from the file listing, they open Pub 97, which correctly posts a box telling me that it cant open the files. If I use Publisher 2003 to open the same files from within the application the work fine. When I select a 2003 Pub file which contains the Pub 97 icon, the file list does not contain Publisher 2003, but when I browse and locat...

Won't Remember Password #2
My email account calls for the password everytime I use it. Even when I check the box to remember my password, it won't retain it. I run XP. Anyone else having problems with this? If you are still having problems after applying both the SP 1 & 2 = patches, then see if this article addresses your problemL OL2002: The Save Password Setting Is Not Saved When You Connect to a = POP3 Server http://support.microsoft.com/default.aspx?scid=3Dkb;en-us;290684 --=81 Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups...

uploading 2 or more mailboxes on 1 user account
I was able to reconnect 1 mailbox to 1 user account, but what i' looking is the way wherein i can reconnect 2 or more mailboxes into user account because instead of giving a 1:1 user account to eac person we will be replacing it and giving them an account per area Hence they already have their own personal account we will b deleting it; How can i put all their messages from their persona account into the single account that we wil be giving to them Hi, More than one mailbox per account is not possible in Exchange 200x. You can do that with Exchange 5.x Regards, -- Menko den Ouden ...

inverting data #2
Please help, I'm stuck! I conducted a survey where respondants each gave answers to 30 questions using a Likert scale i.e. they answered either 1,2,3,4 or 5 to each question. The data is in the following form: Question # q1 q2 q3 q4 q5 1 2 4 2 1 2 2 4 1 2 1 4 3 4 4 2 1 4 4 2 3 2 2 5 5 2 3 4 5 3 My problem is that half of the questions were asked in a negative direction to avoid possible response bias. For the answers to these questions, I need to reverse the answers. If the repondant answered 1, I want to record 5, if 2 then 4, if 3 then 3, if 4 then 2, if 5 then 1. Is there an...