#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
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
Wildcards and if Arlene Excel Worksheet Functions 3 June 21st 07 12:05 AM
Wildcards in RTD JKC Excel Discussion (Misc queries) 0 February 3rd 06 07:35 PM
Wildcards irresistible007 Excel Worksheet Functions 2 December 20th 05 10:12 AM
Use wildcards furia Excel Discussion (Misc queries) 0 November 16th 05 06:23 PM
Wildcards HELP ME PLEASE! Excel Programming 3 December 3rd 03 01:22 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"