Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Wildcards
In my if statement I want to select only cells that start with "8" and are
six characters long. The wild card does not work. How do I limit the cells selected to match the criteria above? T.I.A. Sub PO_Test() Dim i As Long Dim LastRow As Long Dim strPo As String LastRow = Range("A2000").End(xlUp).Row For i = LastRow To 1 Step -1 If Range("A" & i) Like "8*****" Then strPo = Range("A" & i).Value ElseIf Range("D" & i) Like "8*****" Then strPo = Range("D" & i).Value End If Range("H" & i).Value = strPo Next 'i End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Wildcards
Try replacing
"8*****" with "8?????" -- Regards Juan Pablo González "properties" wrote in message ... In my if statement I want to select only cells that start with "8" and are six characters long. The wild card does not work. How do I limit the cells selected to match the criteria above? T.I.A. Sub PO_Test() Dim i As Long Dim LastRow As Long Dim strPo As String LastRow = Range("A2000").End(xlUp).Row For i = LastRow To 1 Step -1 If Range("A" & i) Like "8*****" Then strPo = Range("A" & i).Value ElseIf Range("D" & i) Like "8*****" Then strPo = Range("D" & i).Value End If Range("H" & i).Value = strPo Next 'i End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Wildcards
Hi
try the following: Sub PO_Test() Dim i As Long Dim LastRow As Long Dim strPo As String LastRow = Range("A2000").End(xlUp).Row For i = LastRow To 1 Step -1 if Len(cells(i,"A").value)=6 and Left(cells(i,"A").value,1)="8" then strPo = cells(i,"A").Value elseif Len(cells(i,"D").value)=6 and Left(cells(i,"D").value,1)="8" then strPo = cells(i,"D").Value end if cells(i,"H").value = strPo next End Sub -- Regards Frank Kabel Frankfurt, Germany properties wrote: In my if statement I want to select only cells that start with "8" and are six characters long. The wild card does not work. How do I limit the cells selected to match the criteria above? T.I.A. Sub PO_Test() Dim i As Long Dim LastRow As Long Dim strPo As String LastRow = Range("A2000").End(xlUp).Row For i = LastRow To 1 Step -1 If Range("A" & i) Like "8*****" Then strPo = Range("A" & i).Value ElseIf Range("D" & i) Like "8*****" Then strPo = Range("D" & i).Value End If Range("H" & i).Value = strPo Next 'i End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Wildcards
That works great!
Thanks "Juan Pablo González" wrote in message ... Try replacing "8*****" with "8?????" -- Regards Juan Pablo González "properties" wrote in message ... In my if statement I want to select only cells that start with "8" and are six characters long. The wild card does not work. How do I limit the cells selected to match the criteria above? T.I.A. Sub PO_Test() Dim i As Long Dim LastRow As Long Dim strPo As String LastRow = Range("A2000").End(xlUp).Row For i = LastRow To 1 Step -1 If Range("A" & i) Like "8*****" Then strPo = Range("A" & i).Value ElseIf Range("D" & i) Like "8*****" Then strPo = Range("D" & i).Value End If Range("H" & i).Value = strPo Next 'i End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Wildcards and if | Excel Worksheet Functions | |||
Wildcards in RTD | Excel Discussion (Misc queries) | |||
Wildcards | Excel Worksheet Functions | |||
Use wildcards | Excel Discussion (Misc queries) | |||
Wildcards | Excel Programming |