D
Don
Howdy all,
First off, I'm just a self-taught or rather semi-self-taught user here but I
tried to help out on one of the questions here last week. The OP wanted a
macro that would search down a Col, find a value, stop and let him select
whether to add to that value and put the results in the next Col over same
Row. Here's what I finally came up with and it works great evertime for me
but there may be problems with it as he can't seem to get it to work on his
machine. I'm using XP and Excel2002, the's got Excel2003. If one or more of
you could try the code and see if it does work on other machines I'd be
greatly appreciative. TIA for any help on this issue....Entire code posted
below:
Option Compare Text
Option Explicit
Sub FindReplace()
Dim c As Variant
Dim MySearchValue As Integer
Dim MyString As String
Dim ReplaceWith As String
Dim MyCol As String
Dim Rge As Range
Dim i As Integer
Dim LastRow As Integer
On Error Resume Next
i = 0
MyCol = InputBox("What Column Do You Want To Search?")
With ActiveSheet
LastRow = .Cells(.Rows.Count, MyCol).End(xlUp).Row
End With
MyString = InputBox("What String Do You Wish To Search For?")
ReplaceWith = InputBox("What String Do You Wish To Write?")
Set Rge = Range(MyCol & "1:" & MyCol & LastRow)
For Each c In Rge
MySearchValue = InStr(c, MyString)
i = i + 1
If (Not IsNull(MySearchValue)) And (MySearchValue > 0) Then
Range(MyCol & i).Select
If MsgBox("Is This One To Addend?", vbYesNo + vbInformation) = vbNo
Then
Range(MyCol & i).Offset(0, 1).Value = ""
Else
Range(MyCol & i).Offset(0, 1).Value = ReplaceWith & Range(MyCol
& i)
End If
End If
Next c
End Sub
TIA,
Don
First off, I'm just a self-taught or rather semi-self-taught user here but I
tried to help out on one of the questions here last week. The OP wanted a
macro that would search down a Col, find a value, stop and let him select
whether to add to that value and put the results in the next Col over same
Row. Here's what I finally came up with and it works great evertime for me
but there may be problems with it as he can't seem to get it to work on his
machine. I'm using XP and Excel2002, the's got Excel2003. If one or more of
you could try the code and see if it does work on other machines I'd be
greatly appreciative. TIA for any help on this issue....Entire code posted
below:
Option Compare Text
Option Explicit
Sub FindReplace()
Dim c As Variant
Dim MySearchValue As Integer
Dim MyString As String
Dim ReplaceWith As String
Dim MyCol As String
Dim Rge As Range
Dim i As Integer
Dim LastRow As Integer
On Error Resume Next
i = 0
MyCol = InputBox("What Column Do You Want To Search?")
With ActiveSheet
LastRow = .Cells(.Rows.Count, MyCol).End(xlUp).Row
End With
MyString = InputBox("What String Do You Wish To Search For?")
ReplaceWith = InputBox("What String Do You Wish To Write?")
Set Rge = Range(MyCol & "1:" & MyCol & LastRow)
For Each c In Rge
MySearchValue = InStr(c, MyString)
i = i + 1
If (Not IsNull(MySearchValue)) And (MySearchValue > 0) Then
Range(MyCol & i).Select
If MsgBox("Is This One To Addend?", vbYesNo + vbInformation) = vbNo
Then
Range(MyCol & i).Offset(0, 1).Value = ""
Else
Range(MyCol & i).Offset(0, 1).Value = ReplaceWith & Range(MyCol
& i)
End If
End If
Next c
End Sub
TIA,
Don