Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default "Help Checking Out Macro"

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default "Help Checking Out Macro"

Actually misspoke when I first posted.....the search was for a string (not a
value) and the search string might be only part of a string contained in a
cell....Hope that makes sense...

Don

"Don" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default "Help Checking Out Macro"

Dang....third times a charm...the line breaks have the code messed
up...here's the code with corrections for the line breaks:

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

Hope this works...

Tks again, Don

"Don" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "Help Checking Out Macro"

The charmed version worked ok for me in xl2003.

What happens when it fails for the user?


Don wrote:

Dang....third times a charm...the line breaks have the code messed
up...here's the code with corrections for the line breaks:

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

Hope this works...

Tks again, Don

"Don" wrote:

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


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default "Help Checking Out Macro"

Hi Dave,

Thanks for responding. Here's his statement as to the fairlu

"When I enter D or d, a run-time error 6
occurs (overflow). When I select the debug button it opens up the macro
editor with the line starting with LastRow = highlighted."

I assume he's talking about entering D for the Column although he didn't
clarify that.

I suggested that he eliminate the LastRow step and enter the commands to let
the macro search the entire column he selects (he did state that he was
dealing with several thousand rows, but it'll go through those quite quickly
if it finds no matches). He hasn't responded to that yet but I'd like to
know, if possible, why it fails for him. Good to know that it does work for
someone else.

Thanks Again,

Don


"Dave Peterson" wrote:

The charmed version worked ok for me in xl2003.

What happens when it fails for the user?


Don wrote:

Dang....third times a charm...the line breaks have the code messed
up...here's the code with corrections for the line breaks:

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

Hope this works...

Tks again, Don

"Don" wrote:

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


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "Help Checking Out Macro"

Change all your declarations from "As Integer" to "As Long".

Integers can only go up to 32k. If you have more rows than 32k, those integers
will blow up!

I'd use:

Dim c As Range
Dim MySearchValue As String 'from an inputbox, it's a string
Dim MyString As String
Dim ReplaceWith As String
Dim MyCol As String
Dim Rge As Range
Dim i As Long
Dim LastRow As Long



Don wrote:

Hi Dave,

Thanks for responding. Here's his statement as to the fairlu

"When I enter D or d, a run-time error 6
occurs (overflow). When I select the debug button it opens up the macro
editor with the line starting with LastRow = highlighted."

I assume he's talking about entering D for the Column although he didn't
clarify that.

I suggested that he eliminate the LastRow step and enter the commands to let
the macro search the entire column he selects (he did state that he was
dealing with several thousand rows, but it'll go through those quite quickly
if it finds no matches). He hasn't responded to that yet but I'd like to
know, if possible, why it fails for him. Good to know that it does work for
someone else.

Thanks Again,

Don

"Dave Peterson" wrote:

The charmed version worked ok for me in xl2003.

What happens when it fails for the user?


Don wrote:

Dang....third times a charm...the line breaks have the code messed
up...here's the code with corrections for the line breaks:

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

Hope this works...

Tks again, Don

"Don" wrote:

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


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default "Help Checking Out Macro"

Hi Dave,

This may get posted twice as I got a page too busy back when I posted this
response the first time but here goes....

Thanks for the tip. I did test the macro to 7000 rows but only about 12
cells had anything in them. I'd assume the OP's WS had rows full of data.
I'll make the changes and relay them on to him.

Thanks Again for the Help....

Don

"Dave Peterson" wrote:

Change all your declarations from "As Integer" to "As Long".

Integers can only go up to 32k. If you have more rows than 32k, those integers
will blow up!

I'd use:

Dim c As Range
Dim MySearchValue As String 'from an inputbox, it's a string
Dim MyString As String
Dim ReplaceWith As String
Dim MyCol As String
Dim Rge As Range
Dim i As Long
Dim LastRow As Long



Don wrote:

Hi Dave,

Thanks for responding. Here's his statement as to the fairlu

"When I enter D or d, a run-time error 6
occurs (overflow). When I select the debug button it opens up the macro
editor with the line starting with LastRow = highlighted."

I assume he's talking about entering D for the Column although he didn't
clarify that.

I suggested that he eliminate the LastRow step and enter the commands to let
the macro search the entire column he selects (he did state that he was
dealing with several thousand rows, but it'll go through those quite quickly
if it finds no matches). He hasn't responded to that yet but I'd like to
know, if possible, why it fails for him. Good to know that it does work for
someone else.

Thanks Again,

Don

"Dave Peterson" wrote:

The charmed version worked ok for me in xl2003.

What happens when it fails for the user?


Don wrote:

Dang....third times a charm...the line breaks have the code messed
up...here's the code with corrections for the line breaks:

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

Hope this works...

Tks again, Don

"Don" wrote:

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

--

Dave Peterson


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "Help Checking Out Macro"

I tested with about 5 cells of data.

But I don't use "As Integer" or "as Single" anymore. I use "as Long" and "as
double".

Don wrote:

Hi Dave,

This may get posted twice as I got a page too busy back when I posted this
response the first time but here goes....

Thanks for the tip. I did test the macro to 7000 rows but only about 12
cells had anything in them. I'd assume the OP's WS had rows full of data.
I'll make the changes and relay them on to him.

Thanks Again for the Help....

Don

"Dave Peterson" wrote:

Change all your declarations from "As Integer" to "As Long".

Integers can only go up to 32k. If you have more rows than 32k, those integers
will blow up!

I'd use:

Dim c As Range
Dim MySearchValue As String 'from an inputbox, it's a string
Dim MyString As String
Dim ReplaceWith As String
Dim MyCol As String
Dim Rge As Range
Dim i As Long
Dim LastRow As Long



Don wrote:

Hi Dave,

Thanks for responding. Here's his statement as to the fairlu

"When I enter D or d, a run-time error 6
occurs (overflow). When I select the debug button it opens up the macro
editor with the line starting with LastRow = highlighted."

I assume he's talking about entering D for the Column although he didn't
clarify that.

I suggested that he eliminate the LastRow step and enter the commands to let
the macro search the entire column he selects (he did state that he was
dealing with several thousand rows, but it'll go through those quite quickly
if it finds no matches). He hasn't responded to that yet but I'd like to
know, if possible, why it fails for him. Good to know that it does work for
someone else.

Thanks Again,

Don

"Dave Peterson" wrote:

The charmed version worked ok for me in xl2003.

What happens when it fails for the user?


Don wrote:

Dang....third times a charm...the line breaks have the code messed
up...here's the code with corrections for the line breaks:

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

Hope this works...

Tks again, Don

"Don" wrote:

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

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
Change default in input box from "20" to "000000"? Have macro continue on to name sheet tab? StargateFanFromWork[_4_] Excel Programming 7 October 29th 06 11:46 AM
Shortcut key for "Paste Options" and "Error Checking" buttons? johndog Excel Discussion (Misc queries) 1 October 6th 06 11:56 AM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM


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