I don’t know VBA, I only know how to use the Excel macro recorder and then go and edit / play around with the code.
That said, I have some code that sorts in a descending order according to a set range. Here is the part of the code in question:
Range("D8:J305").Select
Now what I’d like to do is have the user determine the range that is to be sorted. I’d like to be able to put in a value in cell A1 that reads “D8:J100” or perhaps “D8:J58”, etc. You get the idea. I want to be able to manually set my range before executing my macro.
Can anyone tell me how I could modify my code so that it would actually look at the user defined range in cell A1 and then execute it’s sorting steps based upon that unique range? I tried the following but it did not work:
Range(A1).Select
I also tried:
Range(“A1”).Select
Neither worked.
How can I modify the visual basic code so that it is getting it’s range data from cell A1?
Thanks for any help.
jase.
PS,FYI, the entire code is thus:
Sub CurrentlySortAscending()
'' CurrentlySortAscending Macro
' Macro recorded 11/5/2002 by J. Sibley
'
Range("D8:J305").Select
ActiveWindow.ScrollRow = 1
Selection.Sort Key1:=Range("H9"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("D4:J4").Select
End Sub
That said, I have some code that sorts in a descending order according to a set range. Here is the part of the code in question:
Range("D8:J305").Select
Now what I’d like to do is have the user determine the range that is to be sorted. I’d like to be able to put in a value in cell A1 that reads “D8:J100” or perhaps “D8:J58”, etc. You get the idea. I want to be able to manually set my range before executing my macro.
Can anyone tell me how I could modify my code so that it would actually look at the user defined range in cell A1 and then execute it’s sorting steps based upon that unique range? I tried the following but it did not work:
Range(A1).Select
I also tried:
Range(“A1”).Select
Neither worked.
How can I modify the visual basic code so that it is getting it’s range data from cell A1?
Thanks for any help.
jase.
PS,FYI, the entire code is thus:
Sub CurrentlySortAscending()
'' CurrentlySortAscending Macro
' Macro recorded 11/5/2002 by J. Sibley
'
Range("D8:J305").Select
ActiveWindow.ScrollRow = 1
Selection.Sort Key1:=Range("H9"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("D4:J4").Select
End Sub