Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help! Search Range Using Two Criterias & Returning Cell Contents.

Can anyone help?

Problem! I have a table (called "callback") which I can search and
return the cell value using "Cell.Offset". The code listed below
works well. However, I repeat the code four times to get four
different cell values in the same row, based on a single criteria.

Q. 1. Is there away to write this code once and return all four
values that I'm looking for using Cell.Offset?

Q. 2. More importantly, is there away to do the same search using
"two criterias" and returning four cell values? The values are all
located in the row in which the criterias are found.

Bascially, what I'm after is locating a employee based on his/her
employee number and work area. Using these two criteria, once found,
copy their employee particulars to a named range on the worksheet.

Sample Code:

Range("UC").Select
On Error Resume Next
For Each Cell In Range("CallBackList")
If Cell.Value = "PC" Then
Cell.Offset(0, 0).Copy
ActiveCell.PasteSpecial xlPasteValues
ActiveCell.Offset(1, 0).Select
End If
Next Cell

The above code allows me to locate and copy one cell value to my
worksheet.

Thanks for your assistance in advance,
Eugene

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Help! Search Range Using Two Criterias & Returning Cell Contents.

guess the two criterias in the same row
Sub test()
On Error Resume Next

Range("A1:f17").Name = "CallBackList"
i = 0
For Each CELL In Range("CallBackList")
If CELL.Value = "employnumber" And CELL.Offset(, 1) = "workarea" Then
'u can change them with your criterias address
i = i + 1
CELL.Offset(, 2).Copy Range("g" & i) 'u can change the destination u
want to copy to
End If
Next CELL
End Sub

HTH

--
Regards,

Sebation.G

groups.com...
Can anyone help?

Problem! I have a table (called "callback") which I can search and
return the cell value using "Cell.Offset". The code listed below
works well. However, I repeat the code four times to get four
different cell values in the same row, based on a single criteria.

Q. 1. Is there away to write this code once and return all four
values that I'm looking for using Cell.Offset?

Q. 2. More importantly, is there away to do the same search using
"two criterias" and returning four cell values? The values are all
located in the row in which the criterias are found.

Bascially, what I'm after is locating a employee based on his/her
employee number and work area. Using these two criteria, once found,
copy their employee particulars to a named range on the worksheet.

Sample Code:

Range("UC").Select
On Error Resume Next
For Each Cell In Range("CallBackList")
If Cell.Value = "PC" Then
Cell.Offset(0, 0).Copy
ActiveCell.PasteSpecial xlPasteValues
ActiveCell.Offset(1, 0).Select
End If
Next Cell

The above code allows me to locate and copy one cell value to my
worksheet.

Thanks for your assistance in advance,
Eugene



Reply
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
Returning contents of a cell based upon the minimum value in a ran Shawn Excel Worksheet Functions 4 September 2nd 07 08:48 PM
finding the cell with min value and returning the contents of neig Will Excel Worksheet Functions 1 May 17th 07 10:18 PM
Returning contents of a cell in another sheet in same workbook Annette[_2_] Excel Discussion (Misc queries) 1 March 14th 07 04:04 PM
Search criterias? shnim1 Excel Discussion (Misc queries) 1 December 2nd 06 07:55 AM
Returning contents of a cell Dan Excel Worksheet Functions 0 March 26th 06 11:48 PM


All times are GMT +1. The time now is 03:18 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"