LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jbm Jbm is offline
external usenet poster
 
Posts: 28
Default If Then Conditionality Help

First, sorry if this is a double post but it seems my previous attempt
disappeared...

I'm running Excel 2007, and with the starting point of Luke M, I was able to
write this macro:

Sub DataMove()
RowCount = 2
For Each c In Range("B:B")
If c.Value Like "Wooden Shoes" Then
Cells(RowCount, "H").Value = c.Value
Cells(RowCount, "I").Value = c.Offset(0, 1).Value
Cells(RowCount, "J").Value = c.Offset(0, 2).Value
Cells(RowCount, "K").Value = c.Offset(0, 3).Value
Cells(RowCount, "G").Value = c.Offset(0, -1).Value
RowCount = RowCount + 1
End If
Next
End Sub

There are two things I want this macro to do that I can't figure out:
First, I'd like for the macro to search for terms that a cell contains,
instead of the exact values. So I'd like to use "Wood" instead of "Wooden
Shoes" so that my results include things like "Hardwood Floors" as well as
"Wooden Shoes." I'm unsure of what to use instead of 'Like' to do this.
Second, I have about ten separate terms I need to search for, such as "Tile"
and "Soft" and "Wood" instead of only "Wood." I know with 'elseif' I can
repeat lines 4-10, replacing "Wooden Shoes" with "Tile," but that's 7 extra
lines per search term, and the macro balloons in size when I have so many
search terms. Is there a way for the macro to return results for cells that
contain "Tile" and/or "Soft" and/or "Wood" using fewer lines of code?
Once again apologies if this is a double post, I waited about 20 minutes and
the post still seemed to have disappeared. Thanks in advance for any and all
help.
 
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
Conditionality - row to repeat at top Red2003XLT Excel Discussion (Misc queries) 0 July 28th 08 08:16 PM


All times are GMT +1. The time now is 03:12 AM.

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"