Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Searching a Column


I need to search a Column for any cell that is

1. Not Blank
2. Not equal to "Size"
3. Not equal to "Grand Total"

Then select the TWO cells to its left.


  #2   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Searching a Column

You could do something like this:

'Assuming Column C is the one you are searching
'and has a heading.
Set SearchRange = Range("C2:C" & Range("C65536").End
(xlUp).Row)
For Each Cell In SearchRange
If Len(Cell.Value) 0 Then
If Cell.Value < "Size" And _
Cell.Value < "Grand Total" Then
Range(Cell.Offset(0, -2).Address & ":" &
Cell.Offset(0, -1).Address).Select
'Code to do what you're going to do to the two
cells.
End If
End If
Next Cell


Tod
-----Original Message-----

I need to search a Column for any cell that is

1. Not Blank
2. Not equal to "Size"
3. Not equal to "Grand Total"

Then select the TWO cells to its left.


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Searching a Column

Hi Tod,

Thank for your reply. I modified your code a little to do
something a little differently and it works fine. I
modified it to select some different cells from what I
asked to begin with and copy them. One thing I would like
it to do is to copy ALL of the cells that meet
our "search" criteria. Currently it copies the LAST cells
in the range that meet the "search" criteria.

The new code:

Sub TEST2()

Set SearchRange = Range("F2:F" & Range("F65536").End
(xlUp).Row)
For Each Cell In SearchRange
If Len(Cell.Value) 0 And _
Cell.Value < "Size" And _
Cell.Value < "Grand Total" Then
If Cell.Font.Bold = True Then
Range(Cell.Offset(0, 0).Address & ":" &
Cell.Offset(0, -1).Address).Copy
End If
End If
Next Cell

End Sub

Any advice would be appreciated,

Todd
-----Original Message-----
You could do something like this:

'Assuming Column C is the one you are searching
'and has a heading.
Set SearchRange = Range("C2:C" & Range("C65536").End
(xlUp).Row)
For Each Cell In SearchRange
If Len(Cell.Value) 0 Then
If Cell.Value < "Size" And _
Cell.Value < "Grand Total" Then
Range(Cell.Offset(0, -2).Address & ":" &
Cell.Offset(0, -1).Address).Select
'Code to do what you're going to do to the two
cells.
End If
End If
Next Cell


Tod
-----Original Message-----

I need to search a Column for any cell that is

1. Not Blank
2. Not equal to "Size"
3. Not equal to "Grand Total"

Then select the TWO cells to its left.


.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Searching a Column

You'll need to do something with the cells that you've copied before
your code cycles to the next record. Each time the code loops, it'll
replace what you've copied from the last time.

Range(Cell.Offset(0, 0).Address & ":" & Cell.Offset(0,
-1).Address).Copy
'code to do something with copied cells

tod


"ToddG" wrote in message ...
Hi Tod,

Thank for your reply. I modified your code a little to do
something a little differently and it works fine. I
modified it to select some different cells from what I
asked to begin with and copy them. One thing I would like
it to do is to copy ALL of the cells that meet
our "search" criteria. Currently it copies the LAST cells
in the range that meet the "search" criteria.

The new code:

Sub TEST2()

Set SearchRange = Range("F2:F" & Range("F65536").End
(xlUp).Row)
For Each Cell In SearchRange
If Len(Cell.Value) 0 And _
Cell.Value < "Size" And _
Cell.Value < "Grand Total" Then
If Cell.Font.Bold = True Then
Range(Cell.Offset(0, 0).Address & ":" &
Cell.Offset(0, -1).Address).Copy
End If
End If
Next Cell

End Sub

Any advice would be appreciated,

Todd
-----Original Message-----
You could do something like this:

'Assuming Column C is the one you are searching
'and has a heading.
Set SearchRange = Range("C2:C" & Range("C65536").End
(xlUp).Row)
For Each Cell In SearchRange
If Len(Cell.Value) 0 Then
If Cell.Value < "Size" And _
Cell.Value < "Grand Total" Then
Range(Cell.Offset(0, -2).Address & ":" &
Cell.Offset(0, -1).Address).Select
'Code to do what you're going to do to the two
cells.
End If
End If
Next Cell


Tod
-----Original Message-----

I need to search a Column for any cell that is

1. Not Blank
2. Not equal to "Size"
3. Not equal to "Grand Total"

Then select the TWO cells to its left.


.

.

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
Searching for strings in a column [email protected] Excel Worksheet Functions 6 January 23rd 09 06:20 PM
Searching up a column Mike Rogers[_2_] Excel Discussion (Misc queries) 7 December 31st 07 03:46 PM
Searching One Column Only [email protected] Excel Discussion (Misc queries) 2 August 31st 06 12:17 PM
Column searching problem mikeyts New Users to Excel 2 December 18th 04 09:35 PM
Searching In a Column KC[_3_] Excel Programming 4 April 15th 04 02:54 PM


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