Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy and Paste cells in excel using Internet Explorer 1

Status
Not open for further replies.

gremlins

Programmer
Jul 20, 2003
20
GB
I have an excel spreadsheet that I upload on to a web page and so most of my users view the excel sheet through internet explorer.

There is a macro in the sheet that laets you type a name into a cell ("Query Sheet").Cells(2, 3) and then it goes and finds all instance of that name in the data sheet that sits behind it ("Results").

When I run it in excel it works fine, but when I open it through IE6 it copies all of the results to the clipboard and then requests the user to select a cell to paste the value to, rather than executing the insert function.

Please help as I don't want them to keep having to download the whole sheet everytime to make it work properly. I have attached the code it uses.

Sub Find_names()

NameToFind = Worksheets("Query Sheet").Cells(2, 3)
ActiveSheet.Range("A10:AA100").Clear
Selection.Font.Bold = True
Application.ScreenUpdating = False

writerow = 10
With Worksheets("Results").Range("E2:E10000")
Set c = .Find(NameToFind, LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.Address
Do
copyrow = Mid(c.Address, InStrRev(c.Address, "$") + 1, Len(c.Address) - InStrRev(c.Address, "$") + 1)
Sheets("Results").Select
Rows(copyrow).Select
Selection.Copy
Sheets("Query Sheet").Select
Cells(writerow, 1).Insert
Sheets("Results").Select
writerow = writerow + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With

Sheets("Query Sheet").Select
Range("C2").Select

Application.ScreenUpdating = True

End Sub
 
Hi,
Code:
   Sheets("Results").Rows(copyrow).Copy _
   Destination:=Sheets("Query Sheet").Cells(writerow, 1)
Take a look at this FAQ. Try to MINIMIZE or ELIMINATE Activating and Selecting.

How Can I Make My Code Run Faster? faq707-4105


Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Cheers Skip,

That's worked a treat, and the FAQ means I can stop using about half a dozen lines of unnecessary code.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top