LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Find problem

I'm trying to search one file for a staff number and then copy the
information in the cells to the right into another file.

The problem is with "Cells.Find(What:=Windows("users.xls").ActiveC ell,
......."

I want to search for the contents of the currently selected cell of the
other sheet.
Another way to do this would be to copy and then search for the
contents of the clipboard but I couldn't find any examples of that
either.
I also tried to copy the number to a variable and search for the
variable name but that didn't work for me. (2nd piece of code)


Thanks for any help. I should hopefully soon have my first piece of VBA
code written!




' Switch to sheet to fill
Windows("users.xls").Activate
Range("c104").Select

' Switch to sheet to search
Windows("list.xls").Activate

' Search the sheet for staff number as selected in other sheet
Cells.Find(What:=Windows("users.xls").ActiveCell, After:="A1",
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False).Activate

' Select the cells to the right of what is found and copy
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy

' Switch to sheet to fill to paste results
Windows("users.xls").Activate

' The correct cell will be active, paste.
ActiveSheet.Paste

' Repeat

ActiveCell.Offset(1, 0).Select





' Switch to sheet to fill
Windows("users.xls").Activate
Range("c104").Select
staffnumber = ActiveCell.Value


' Switch to sheet to search
Windows("list.xls").Activate

' Search the sheet for staff number as selected in other sheet
Cells.Find(What:=staffnumber, After:="A1", LookIn:=xlFormulas,
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with 'Find' Dave Excel Discussion (Misc queries) 5 December 15th 09 01:27 PM
problem with FIND cjsmith22 Excel Worksheet Functions 3 November 17th 05 11:03 PM
find problem John Excel Programming 4 July 3rd 04 08:30 AM
find problem jon Excel Programming 2 May 24th 04 11:27 AM
Problem with FIND LSB Excel Programming 2 January 12th 04 04:16 AM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"