I put comments in the code to suggest what the code would do.
Sub RunRandom()
'Select A2:A635
Range("A2:A635").Select
Selection.Copy
Range("B2").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
' Now B2:B635 should have the same information as column A
' next line turns off the marquee
Application.CutCopyMode = False
' Filter column C1:C638 so only unique entries are displayed
Range("C1:C638").AdvancedFilter Action:=xlFilterInPlace, Unique:= _
True
Range("E2").Select
' sort all data contiguous to E2 based on values in Column B
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom
' Number column D sequentially starting in D2
Range("D2").Select
ActiveCell.FormulaR1C1 = "1"
Range("D3").Select
ActiveCell.FormulaR1C1 = "2"
Range("D2:D3").Select
Selection.AutoFill Destination:=Range("D2:D638"), Type:= _
xlFillDefault
Range("D2:D151").Select
Range("A1").Select
End Sub
It doesn't appear to do what you describe and would overwrite the data in
columns B and D for sure.
They told you this was working? Notice that there is no code in it to ever
address any sheet but the activesheet. It might be possible that the code
assumes it is working on a sheet where the data has been copied to column E
(and to the right) and additional formulas added in columns A:D (such as
code to generate random numbers in column B).
--
Regards,
Tom Ogilvy
"Bob" wrote in message
. ..
I have been "volunteered" take over from a fellow (now unavailable to me)
in
the preparation of an exam for voluntary certification.
The contents are as follows.
a-Original question number
b- question
c-choice of answer
d-choice of answer
e-choice of answer
f-choice of answer
g-choice of answer
h-answer
The exam is set up to be multiple choice. The person taking the exam gets
the questions and the person marking gets the answer paper.
Hope this gives a bit more information.
Thanks
Bob
"Tushar Mehta" wrote in message
news:MPG.1b1f1523162334e8989801@news-server...
Not that answering these questions guarantees a satisfactory resolution
to your problem, but...
What are the contents of A:E before you run the macro?
What is the purpose of the macro? What is the intent behind each of
the major operations (AdvancedFilter, Sort, AutoFill) in the macro?
What do you need help with?
--
Regards,
Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
In article ,
says...
Sorry to be such a nuisance but I am new at Excel macros and have been
put
into a situation where I have to get some stuff up and running in a
short
time. I was conscripted into a volunteer position and could sure use
some
guidance.
I was given a file with a total of 635 lines of questions and a macro
(below) that is supposed to select 100 questions and answers (seperate
documents)
Sub RunRandom()
Range("A2:A635").Select
Selection.Copy
Range("B2").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("C1:C638").AdvancedFilter Action:=xlFilterInPlace, Unique:=
_
True
Range("E2").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom
Range("D2").Select
ActiveCell.FormulaR1C1 = "1"
Range("D3").Select
ActiveCell.FormulaR1C1 = "2"
Range("D2:D3").Select
Selection.AutoFill Destination:=Range("D2:D638"), Type:= _
xlFillDefault
Range("D2:D151").Select
Range("A1").Select
End Sub
My understanding is that the questions are supposed to be printed on
one
document and the answers on another.
I intend to buy a book so I don't have to rely on others but could
really
use some help until I get a bit of an understanding.
Thanks sincerely
Bob