Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro and wildcard

I am trying to get a wildcard to work in a macro.

Sub Merge()
Dim intRow As Integer
Dim txt As String
intRow = 1
Do Until IsEmpty(Cells(intRow, 2))
If Cells(intRow, 2) = "0x" Then
Cells(intRow, 2) = Cells(intRow, 24)
If Cells(intRow, 24) = "ip:source-ip=192.168.1.*" Then
Cells(intRow, 2) = "value 3"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.2.*" Then
Cells(intRow, 2) = "value 2"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.3.*" Then
Cells(intRow, 2) = "value 1"
End If
End If
intRow = intRow + 1
Loop
Columns(1).AutoFit
End Sub

Will this wildcard logic work at all? I know as it currently is it will
not.

Any help appreciated

thanks

Roger


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default macro and wildcard

Roger,

Use the Like operator. E.g.,

If Cells(intRow, 24) Like "ip:source-ip=192.168.1.*" Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Roger" wrote in message
...
I am trying to get a wildcard to work in a macro.

Sub Merge()
Dim intRow As Integer
Dim txt As String
intRow = 1
Do Until IsEmpty(Cells(intRow, 2))
If Cells(intRow, 2) = "0x" Then
Cells(intRow, 2) = Cells(intRow, 24)
If Cells(intRow, 24) = "ip:source-ip=192.168.1.*" Then
Cells(intRow, 2) = "value 3"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.2.*" Then
Cells(intRow, 2) = "value 2"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.3.*" Then
Cells(intRow, 2) = "value 1"
End If
End If
intRow = intRow + 1
Loop
Columns(1).AutoFit
End Sub

Will this wildcard logic work at all? I know as it currently is it will
not.

Any help appreciated

thanks

Roger




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default macro and wildcard

Or:

If Left(Cells(intRow, 24),23) = "ip:source-ip=192.168.1." Then

--
HTH,
Dianne

In ,
Roger typed:
I am trying to get a wildcard to work in a macro.

Sub Merge()
Dim intRow As Integer
Dim txt As String
intRow = 1
Do Until IsEmpty(Cells(intRow, 2))
If Cells(intRow, 2) = "0x" Then
Cells(intRow, 2) = Cells(intRow, 24)
If Cells(intRow, 24) = "ip:source-ip=192.168.1.*" Then
Cells(intRow, 2) = "value 3"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.2.*" Then
Cells(intRow, 2) = "value 2"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.3.*" Then
Cells(intRow, 2) = "value 1"
End If
End If
intRow = intRow + 1
Loop
Columns(1).AutoFit
End Sub

Will this wildcard logic work at all? I know as it currently is it
will not.

Any help appreciated

thanks

Roger



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default macro and wildcard

Roger

Delete the "*" and replace the "=" with Like this might do
the trick

Peter Atherton
-----Original Message-----
I am trying to get a wildcard to work in a macro.

Sub Merge()
Dim intRow As Integer
Dim txt As String
intRow = 1
Do Until IsEmpty(Cells(intRow, 2))
If Cells(intRow, 2) = "0x" Then
Cells(intRow, 2) = Cells(intRow, 24)
If Cells(intRow, 24) = "ip:source-ip=192.168.1.*"

Then
Cells(intRow, 2) = "value 3"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.2.*"

Then
Cells(intRow, 2) = "value 2"
End If
If Cells(intRow, 24) = "ip:source-ip=192.168.3.*"

Then
Cells(intRow, 2) = "value 1"
End If
End If
intRow = intRow + 1
Loop
Columns(1).AutoFit
End Sub

Will this wildcard logic work at all? I know as it

currently is it will
not.

Any help appreciated

thanks

Roger


.

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
Trying to CF using a wildcard toonarme Excel Discussion (Misc queries) 3 July 18th 10 10:52 PM
Using the wildcard with IF DamienO New Users to Excel 5 January 29th 09 01:51 AM
If and wildcard Fish Excel Discussion (Misc queries) 3 October 1st 08 01:33 AM
using wildcard for vlookup? Steve Excel Discussion (Misc queries) 1 November 9th 07 06:18 PM
sum if wildcard Marcel New Users to Excel 1 April 30th 06 11:25 AM


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