Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trying to CF using a wildcard | Excel Discussion (Misc queries) | |||
Using the wildcard with IF | New Users to Excel | |||
If and wildcard | Excel Discussion (Misc queries) | |||
using wildcard for vlookup? | Excel Discussion (Misc queries) | |||
sum if wildcard | New Users to Excel |