Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditionality - row to repeat at top | Excel Discussion (Misc queries) |