Excel Macro Selection

I

Icy

Hello could anyone help, I worte a code which select record from same user in
the excel sheet and name the selection "First". Once run through all the
record, it will call selection "First" then copy and paste it onto the serach
result sheet. The code listed works fine until the user records are over
150. The function will give me a error "Run-Time error'1004':
Application-defined or object-defined error". Could anyone help, or any good
suggest on how to achive this.
Thanks so much.

Range(Cells(1, 1), Cells(1, 81)).Select
Selection.Name = "First"

For I=2 to Last
Name = Cells(I,3)
If (Name = Target) Then
Range(Cells(I, 1), Cells(I, 81)).Select
Selection.Name = "Second"
Range("First, Second").Select
Selection.Name = "First"

Next I
 
B

Bob Phillips

For i = 2 To Last
Name = Cells(i, 3)
If Name = Target Then
Range(Cells(i, 1), Cells(i, 81)).Name = "Second"
Range("First, Second").Name = "First"
End If
Next i

Not a good idea to use Name as a variable.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
I

Icy

Thank you for your reply, it's still showing the same error message, it won't
let me go over 150 records, any idea, or better code that can achive this.
Thanks for help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top